-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from advanced-security/mbaluda/type_sanitizer
Exclude injection alerts where the input data type is not String
- Loading branch information
Showing
13 changed files
with
166 additions
and
10 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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 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 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 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 } | ||
|
||
/* API to talk to Service. */ | ||
action send ( | ||
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 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! | ||
}); | ||
}) |