-
Notifications
You must be signed in to change notification settings - Fork 2
Exclude injection alerts where the input data type is not String #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
341ef89
Add simple test case with type in the service cds file
mbaluda 8495980
Update service.js
mbaluda d2f15cd
Merge branch 'main' into mbaluda/type_sanitizer
mbaluda f49d76d
Merge branch 'main' into mbaluda/type_sanitizer
jeongsoolee09 2cab33a
Merge branch 'main' into mbaluda/type_sanitizer
jeongsoolee09 b5033bd
Update test project: README and package-lock.json
jeongsoolee09 efd3470
Implement `HandlerParameterData.getType/0`
jeongsoolee09 671c25d
Merge branch 'mbaluda/type_sanitizer' of github.com:advanced-security…
jeongsoolee09 dab5a75
Minor comment formatting
jeongsoolee09 201cb41
Merge branch 'jeongsoolee09/remove-loginjection-single-file' into mba…
jeongsoolee09 2a3503b
Merge branch 'main' into mbaluda/type_sanitizer
jeongsoolee09 c9798e6
Update javascript.sarif.expected
jeongsoolee09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...frameworks/cap/test/queries/loginjection/log-injection-type-sanitized/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Sanitized Log Injection | ||
|
||
This application demonstrates how a potential injection vulnerability is not reported if the data type definied in the service description is not strings. | ||
|
||
## It _is_ a false positive case | ||
|
||
Service responds to a Received event and logs the data. However, the type of the message (Integer) does not allow for the injection to succeed. |
11 changes: 11 additions & 0 deletions
11
...cript/frameworks/cap/test/queries/loginjection/log-injection-type-sanitized/db/schema.cds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace advanced_security.log_injection.sample_entities; | ||
|
||
entity Entity1 { | ||
Attribute1 : String(100); | ||
Attribute2 : String(100) | ||
} | ||
|
||
entity Entity2 { | ||
Attribute3 : String(100); | ||
Attribute4 : String(100) | ||
} |
3 changes: 3 additions & 0 deletions
3
...t/queries/loginjection/log-injection-type-sanitized/log-injection-type-sanitized.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nodes | ||
edges | ||
#select |
1 change: 1 addition & 0 deletions
1
...test/queries/loginjection/log-injection-type-sanitized/log-injection-type-sanitized.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loginjection/LogInjection.ql |
21 changes: 21 additions & 0 deletions
21
...script/frameworks/cap/test/queries/loginjection/log-injection-type-sanitized/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@advanced-security/log-injection", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"@cap-js/sqlite": "*", | ||
"@sap/cds": "^7.9.5", | ||
"@sap/cds-dk": "^8.6.1", | ||
"express": "^4.17.1" | ||
}, | ||
"scripts": { | ||
"start": "cds-serve", | ||
"watch": "cds watch" | ||
}, | ||
"cds": { | ||
"requires": { | ||
"service": { | ||
"impl": "srv/service.js" | ||
} | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
javascript/frameworks/cap/test/queries/loginjection/log-injection-type-sanitized/server.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const cds = require('@sap/cds'); | ||
const app = require('express')(); | ||
|
||
cds.serve('all').in(app); |
11 changes: 11 additions & 0 deletions
11
...ipt/frameworks/cap/test/queries/loginjection/log-injection-type-sanitized/srv/service.cds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using { advanced_security.log_injection.sample_entities as db_schema } from '../db/schema'; | ||
|
||
service Service @(path: '/service') { | ||
/* Entity to send READ/GET about. */ | ||
entity ServiceEntity as projection on db_schema.Entity2 excluding { Attribute4 } | ||
Check warningCode scanning / CodeQL Entity exposed without authentication Medium test
The CDS entity Service.ServiceEntity is exposed without any authentication.
|
||
|
||
/* API to talk to Service. */ | ||
action send ( | ||
Check warningCode scanning / CodeQL Entity exposed without authentication Medium test
The CDS action Service.send is exposed without any authentication.
|
||
messageToPass: Integer | ||
) returns String; | ||
} |
11 changes: 11 additions & 0 deletions
11
...ript/frameworks/cap/test/queries/loginjection/log-injection-type-sanitized/srv/service.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const cds = require("@sap/cds"); | ||
const LOG = cds.log("logger"); | ||
|
||
module.exports = cds.service.impl(function() { | ||
/* Log upon receiving an "send" event. */ | ||
this.on("send", async (msg) => { | ||
const { messageToPass } = msg.data; | ||
/* A log injection sink. */ | ||
LOG.info("Received: ", messageToPass); // messageToPass is Integer, not a log injection! | ||
|
||
}); | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Entity exposed without authentication Medium test