Make CAP Log injection query more resilient and conservative#226
Merged
jeongsoolee09 merged 6 commits intomainfrom Aug 27, 2025
Merged
Make CAP Log injection query more resilient and conservative#226jeongsoolee09 merged 6 commits intomainfrom
jeongsoolee09 merged 6 commits intomainfrom
Conversation
knewbury01
reviewed
Aug 26, 2025
Contributor
knewbury01
left a comment
There was a problem hiding this comment.
can we add a test case that shows the interprocedural case for the req params? nice work on that though, that totally makes sense to add!
additionally there are some current unit test changes, are those expected?
knewbury01
reviewed
Aug 26, 2025
knewbury01
reviewed
Aug 26, 2025
Co-authored-by: Kristen Newbury <knewbury01@github.com>
Co-authored-by: Kristen Newbury <knewbury01@github.com>
…advanced-security/codeql-sap-js into jeongsoolee09/improve-cap-log-injection
Contributor
Author
|
@knewbury01 Test cases are added in f2511a2. |
27 tasks
19 tasks
36 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What This PR Contributes
This PR contributes two things to the CAP log injection query: making it more resilient and more conservative.
Make the query more resilient
It is observed that the request parameter object can be tossed around interprocedurally until it is read downstream. For example:
The untrusted property
req.datais read in a callee downstream. This code previously could not be detected since property reads are tracked only locally. Therefore, wrap the request parameter definition in a type tracker to track it inter-procedurally.Make the query more conservative
A CDS element declared in a
.cdsfile can lack its type information for several reasons, notably because it borrows its type interface from one of the common aspects that comes with the NPM package@sap/cdswhich CodeQL analysis can't get to. In this case, it makes sense to be conservative and decide that a request parameter is a barrier only if its matching type information can statically be found in its CDS declaration and it's eitherStringorLargeString. That is, the query now conservatively decides that the request parameter data can be an injection vector if it can't be sure it's a string type, even if in fact it is not a string type.Future Works
None at the moment.