Ruby-China Mongodb injection can cause theft of the identity of administrators (Others) to post messages

Source: Internet
Author: User
Tags mongodb injection mongodb query

Ruby-China Mongodb injection can cause theft of the identity of administrators (Others) to post messages

First, mongodb injection will not cause problems if the query string is passed as a variable value.


However, the input parameter name is controllable, and a problem occurs when you obtain the input parameter.

Http://www.baidu.com/index? Username [$ ne] = x

If you get the username and enter the mongodb query, the username value is not x.



 



This is a local test environment. node. js + mongoose + mongodb can be seen and parsed into multi-dimensional arrays. The mongodb operator is also inserted into the final query results, and the username is not the value of x.



Now that the preparations have been completed, start to the topic:

The Ruby-China Post API uses tokens for identity verification. each user has a token value.



Now let's call the posting api and set the post title content and key id tokens to the $ gt operator.


 





If $ gt is greater than or equal to, the token is used to verify the identity, so the token [$ gt] = 123 becomes such a statement.

Db. xxx. find ({"token": {"$ gt": 123}) returns all users whose token value is greater than or equal to 123.

Then, only the first record is used for posting. The first record must be an administrator, so you can steal the identity of the Administrator to post the post.




 


 


 


Solution:

Strictly filter parameters

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.