Feat: Add NoSQL Injection Vulnerability Level 1#502
Feat: Add NoSQL Injection Vulnerability Level 1#502subhamkumarr wants to merge 17 commits intoSasanLabs:masterfrom
Conversation
|
@subhamkumarr please run ./gradlew spotlessApply and submit PR again. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #502 +/- ##
============================================
+ Coverage 49.33% 49.48% +0.15%
- Complexity 346 355 +9
============================================
Files 56 59 +3
Lines 2090 2144 +54
Branches 225 228 +3
============================================
+ Hits 1031 1061 +30
- Misses 978 1001 +23
- Partials 81 82 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@subhamkumarr can you please review sample vulnerability related classes and files? |
| @VulnerableAppRequestMapping( | ||
| value = LevelConstants.LEVEL_1, | ||
| htmlTemplate = "LEVEL_1/NoSQLInjection_Level1") | ||
| public ResponseEntity<GenericVulnerabilityResponseBean<String>> getVulnerablePayloadLevel1( |
There was a problem hiding this comment.
possible to add more levels including secure level?
| if (mongoTemplate.collectionExists(User.class)) { | ||
| mongoTemplate.dropCollection(User.class); | ||
| } | ||
| mongoTemplate.save(new User("admin", "SecretPassword123", "Admin User")); |
There was a problem hiding this comment.
you can look at configuration file which has other beans like H2 database, https://github.com/SasanLabs/VulnerableApp/blob/master/src/main/java/org/sasanlabs/configuration/VulnerableAppConfiguration.java
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.sasanlabs.service.vulnerability.bean.GenericVulnerabilityResponseBean; |
There was a problem hiding this comment.
Remove sample vulnerability related classes.
| @@ -0,0 +1,37 @@ | |||
| package org.sasanlabs.service.vulnerability.sampleVulnerability; | |||
|
|
|||
| import org.sasanlabs.internal.utility.LevelConstants; | |||
|
@subhamkumarr are you working on this? |
Description
This PR implements NoSQL Injection Vulnerability Level 1, addressing issue #497.
Changes
spring-boot-starter-data-mongodbandde.flapdoodle.embed.mongotobuild.gradlefor embedded MongoDB support.NOSQL_INJECTIONtoVulnerabilityType.java.NoSQLInjectionVulnerability.java.getVulnerablePayloadLevel1which constructs aBasicQueryusing string concatenation, allowing NoSQL injection.NoSQLInjection_Level1.htmlandjsto allow users to interact with the vulnerability.How to Verify
guestand click Search. You should see the user details.guest" || "1"=="1or similar payload (depending on the query logic) to break out of the query.BasicQuerywith string concatenation passed tomongoTemplate.find(), it simulates a JSON injection or$whereclause injection depending on context. The logic explicitly constructs{ "username": "<input>" }.admin", "password": { "$ne": "1" }.{ "username": "admin", "password": { "$ne": "1" } }.Dependencies