Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 not_ 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.
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)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodes
edges
#select
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loginjection/LogInjection.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@advanced-security/log-injection",
"version": "1.0.0",
"dependencies": {
"@sap/cds": "^7",
"express": "^4.17.1",
"@cap-js/sqlite": "*"
},
"scripts": {
"start": "cds-serve",
"watch": "cds watch"
},
"cds": {
"requires": {
"service": {
"impl": "srv/service.js"
}
}
}
}
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);
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') {

Check warning

Code scanning / CodeQL

Entity exposed without authentication Medium test

The CDS service Service is exposed without any authentication.
/* Entity to send READ/GET about. */
entity ServiceEntity as projection on db_schema.Entity2 excluding { Attribute4 }

Check warning

Code 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 warning

Code scanning / CodeQL

Entity exposed without authentication Medium test

The CDS action Service.send is exposed without any authentication.
messageToPass: Integer
) returns String;
}
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); // CAP log injection alert
});
})