douzhuangna6906 2015-08-12 16:12
浏览 39

Couchbase注射?

Couchbase is a relatively new NoSql database. Like any other new technology, it comes with some security concerns. I've spent quite a time to understand the risk of injection using go-couchbase client library. According to their documentation, I know that it is possible to form Schema and javascript injection attacks. However, I was not able to form any nasty attack. It seems like plain string values are not being parsed(eval) on the Couchbase side. Here is my sample:

cbbucket, err = cbpool.GetBucketWithAuth(bi.Name, bi.Name, bi.Password)
if err != nil {
    fmt.Printf("Failed to connect to bucket %s %v", bi.Name, err)
    return
}
input := `{"v1":"Malicous"}`
err = cbbucket.Set("k1", 0, input)
if err != nil {
    fmt.Printf("set failed error %v", err)
    return
}

I assume, the input is the point where an attacker can manipulate data. Nevertheless what is stored in the Couchbase is harmless(escaped) version of the input. Here is the stored value in the DB:

"{\"v1\":\"Malicous\"}"

By looking at the encoding/json package, I came to know that go can parse generic JSON objects on the fly using interface{}. Therefore, I have modified my exploitation code as follows:

cbbucket, err = cbpool.GetBucketWithAuth(bi.Name, bi.Name, bi.Password)
if err != nil {
    fmt.Printf("Failed to connect to bucket %s %v", bi.Name, err)
    return
}
input := `{"v1":"Malicous"}`
b := []byte(input)
var f interface{}
err := json.Unmarshal(b, &f)
err = cbbucket.Set("k1", 0, &f)
if err != nil {
    fmt.Printf("set failed error %v", err)
    return
}

This time the exploitation is successfully done. Here is the malicious JSON object stored in the Couchbase:

{
  "v1": "Malicous"
}

Well, this exploitation is not so exciting... as it really requires the developer to blindly Unmarshal user input and store it in the the DB. I was wondering if there are other easier exploitation techniques, derived from string concatenation, which does not require such a huge carelessness.

  • 写回答

1条回答 默认 最新

  • duanpengya7074 2015-08-12 18:38
    关注

    For access via key like you are doing, Couchbase does not parse or validate the value being written into the database. That is an application side function. As long as the value is in a form Couchbase Server understands, it is just written as the value for that object.

    评论

报告相同问题?

悬赏问题

  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误