Skip to content

Commit 341ef89

Browse files
committed
Add simple test case with type in the service cds file
1 parent 23aadaf commit 341ef89

File tree

8 files changed

+68
-0
lines changed

8 files changed

+68
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Sanitized Log Injection
2+
3+
This application demonstrates how a potential injection vulnerability is not reported if the data type definied in the service description is not strings.
4+
5+
## It _is not_ a false positive case
6+
7+
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.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace advanced_security.log_injection.sample_entities;
2+
3+
entity Entity1 {
4+
Attribute1 : String(100);
5+
Attribute2 : String(100)
6+
}
7+
8+
entity Entity2 {
9+
Attribute3 : String(100);
10+
Attribute4 : String(100)
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodes
2+
edges
3+
#select
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
loginjection/LogInjection.ql
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@advanced-security/log-injection",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"@sap/cds": "^7",
6+
"express": "^4.17.1",
7+
"@cap-js/sqlite": "*"
8+
},
9+
"scripts": {
10+
"start": "cds-serve",
11+
"watch": "cds watch"
12+
},
13+
"cds": {
14+
"requires": {
15+
"service": {
16+
"impl": "srv/service.js"
17+
}
18+
}
19+
}
20+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const cds = require('@sap/cds');
2+
const app = require('express')();
3+
4+
cds.serve('all').in(app);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using { advanced_security.log_injection.sample_entities as db_schema } from '../db/schema';
2+
3+
service Service @(path: '/service') {
4+
/* Entity to send READ/GET about. */
5+
entity ServiceEntity as projection on db_schema.Entity2 excluding { Attribute4 }
6+
7+
/* API to talk to Service. */
8+
action send (
9+
messageToPass: Integer
10+
) returns String;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const cds = require("@sap/cds");
2+
const LOG = cds.log("logger");
3+
4+
module.exports = cds.service.impl(function() {
5+
/* Log upon receiving an "send" event. */
6+
this.on("send", async (msg) => {
7+
const { messageToPass } = msg.data;
8+
/* A log injection sink. */
9+
LOG.info("Received: ", messageToPass); // CAP log injection alert
10+
});
11+
})

0 commit comments

Comments
 (0)