TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

MongoDB remote command execution vulnerability: nightmare or eye opener?

70 点作者 ehsanf大约 12 年前

7 条评论

sehrope大约 12 年前
Having your DB server (regardless of type) exposed to the entire internet is a bad idea but that's not the real problem here (it just makes this <i>really</i> scary for people running wide open MongoDB instances). This is a lack of validation of client inputs by the server itself and (in my opinion) a dangerous default choice of trusting your client.<p>Most DBs allow something similar to this though it's generally locked down by default.<p>For PostgreSQL you can do it via untrusted languages though by default only super users can use those: <a href="http://www.postgresql.org/docs/9.1/static/plperl-trusted.html" rel="nofollow">http://www.postgresql.org/docs/9.1/static/plperl-trusted.htm...</a><p>For Oracle here's a bunch of ways to accomplish the same thing though again, by default, all are blocked for non-DBA users: <a href="http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:16212348050" rel="nofollow">http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTI...</a><p>Note that there are some times when it's useful to be able to execute misc things like this. About 6 or 7 years back I wrote something on Oracle that would execute shell commands to get iostat/vmstat output and save it on regular intervals. Could have been done from outside in (data gets pushed from unix =&#62; DB) but having it initiated by the DB itself let us control when it runs based on DB actions (triggers, DBMS_JOBs, etc). To get that setup though we had to whitelist the executables we were calling as by default on Oracle everything is blocked. It's not a common thing to do and I think it's sensible that things like that should be locked down by default.
optymizer大约 12 年前
This relies on javascript to be passed to $where. There is no excuse for not sanitizing your inputs.
评论 #5452685 未加载
abentspoon大约 12 年前
Thanks to $elemMatch and automatic parameter parsing, this vulnerability is easier to exploit than it would seem.<p>In rails, both of these are usually considered safe:<p><pre><code> MysqlCollection.create(:name =&#62; params[:name]) MysqlCollection.where(:name =&#62; params[:name]).all MongoCollection.create(:name =&#62; params[:name]) MongoCollection.where(:name =&#62; params[:name]).all </code></pre> However, the mongo version is vulnerable to this exploit.<p><pre><code> /create?name[0][whatever]=anything /get?name[$elemMatch][$where]=exploitcode</code></pre>
评论 #5451865 未加载
wheaties大约 12 年前
As a developer that uses MongoDB in production I am shocked! Shocked, I tell you.
评论 #5450605 未加载
nickporter大约 12 年前
I guess this is only a real problem if you're exposing your MongoDB instance to the internet.
评论 #5451032 未加载
评论 #5450720 未加载
评论 #5453223 未加载
cheald大约 12 年前
This seems like Seriously Bad News for folks like MongoHQ. I'm hoping they're running 2.4.1, though?
评论 #5451525 未加载
shin_lao大约 12 年前
Doesn't the MongoDB daemon run in a privilege-free sandboxed environment?
评论 #5450515 未加载
评论 #5450436 未加载