Skip to content

fix: scan-status gate bypassed by /content/$value requests - #510

Closed
cschuerings wants to merge 3 commits into
cap-js:mainfrom
cschuerings:fix/status-gate
Closed

fix: scan-status gate bypassed by /content/$value requests#510
cschuerings wants to merge 3 commits into
cap-js:mainfrom
cschuerings:fix/status-gate

Conversation

@cschuerings

Copy link
Copy Markdown
Contributor

Problem

Infected attachments could be downloaded via the OData /$value suffix (GET /content/$value) because the scan-status gate in validateAttachment only checked for /content and /_content suffixes:

if (reqUrl?.endsWith("/content") || /\/[^/]*_content$/.test(reqUrl)) {

Both patterns miss the /$value suffix, so the gate was never entered for:

  • /odata/v4/.../content/$value
  • /odata/v4/.../foo_content/$value

The same blind spot affected getScanInfo where the prefix was extracted with split('/').pop().replace('_content', '') — for a /$value URL this returns "$value" instead of the actual field prefix, causing the DB query to look up the wrong column.

Fix

Introduce two helper functions in lib/helper.js:

  • isContentRequest(url) — matches all four content URL variants (/content, /content/$value, /field_content, /field_content/$value) after stripping query string and fragment.
  • extractContentPrefix(url) — strips the /$value suffix before extracting the inline-attachment field prefix; returns undefined for the composition-based /content pattern.

Both are used in validateAttachment, getScanInfo, and readAttachment, replacing the scattered inline string-matching logic.

Tests

  • tests/unit/contentUrlHelpers.test.js — 23 unit tests covering both helpers directly (true/false cases, /$value, query strings, fragments, null/undefined).
  • tests/unit/status-gate.test.js — 3 integration-style tests that call validateAttachment with an Infected attachment via /content, /content/$value, and /foo_content/$value URLs and assert req.reject(403, ...) is called in all cases.

@cschuerings
cschuerings requested a review from a team as a code owner August 4, 2026 14:54
@eric-pSAP eric-pSAP mentioned this pull request Aug 7, 2026
eric-pSAP added a commit that referenced this pull request Aug 17, 2026
Duplicate of #510  to allow for merging.

---------

Co-authored-by: Christian Schuerings <christian.schuerings@sap.com>
Co-authored-by: hyperspace-pr-bot[bot] <209611008+hyperspace-pr-bot[bot]@users.noreply.github.com>
@eric-pSAP

Copy link
Copy Markdown
Contributor

Merged with PR #517

@eric-pSAP eric-pSAP closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants