litmuschaos / litmus

Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https://hub.litmuschaos.io). Community notes is at https://hackmd.io/a4Zu_sH4TZGeih-xCimi3Q
https://litmuschaos.io
Apache License 2.0
4.44k stars 697 forks source link

[Security] Added 'eq' operation when querying entitiy #4820

Closed sukkyun2 closed 3 months ago

sukkyun2 commented 3 months ago

Proposed changes

This is a fix for the security vulnerability Database query built from user-controlled sources raised by CodeQL.

The issue arises when passing an entity identity without using the $eq operation

References recommend using $eq to enhance security.

This code is an example of the modified code.

//AS-IS
query := bson.D{{"_id", projectID}}

//TO-BE
query := bson.D{{"_id", bson.D{{"$eq", projectID}}}} // uses the $eq operation

References

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Dependency

Special notes for your reviewer:

namkyu1999 commented 3 months ago

This pr soloved below security issues