Skip to content

test: replace WAF-blocked payloads in ErrorHandling special-case tests - #399

Merged
cs-raj merged 1 commit into
feature/comprehensive-integration-testsfrom
fix/waf-blocked-error-handling-payloads
Nov 23, 2026
Merged

cs-raj merged 1 commit into
feature/comprehensive-integration-testsfrom
fix/waf-blocked-error-handling-payloads

Conversation

@cs-raj

@cs-raj cs-raj commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem

Error_XSSAttempt_SafelyHandled in test/integration/ErrorTests/ErrorHandling.test.js fails at random in sdk-js-cda-daily-sanity:

SyntaxError: Unexpected token '<', "<html>..." is not valid JSON

It sends <script>alert("xss")</script> as a where() value. The Cloudflare WAF on dev11 sometimes blocks that request and returns an HTML 403 page, so response.json() throws. Same commit (45a5af5), different results:

Run Date Result
#770 Nov 17 ✅
#771 Nov 18 ❌ HTML response
#772–#775 Nov 18–20 ✅
#776–#781 Nov 23 ❌ HTML response

45a5af5 already fixed this for WhereOperators and ExistsSearchOperators but missed these two tests. Error_SQLInjectionAttempt_SafelyHandled sends '; DROP TABLE entries; --, the exact string that was blocked in WhereOperators on Nov 16, so it is at risk too.

Fix

Same approach as 45a5af5: replace both tests with URL metacharacter values, which are what can actually break a query string the SDK builds:

  • Error_QueryDelimitersInValue_TreatedAsLiteral: foo&limit=100 must not inject a second param (also checks no more than 3 entries come back).
  • Error_PercentPlusHashInValue_HandledSafely: 100% a+b #1, where % must not be double-encoded, + must not become a space, and # must not truncate the query.

Every character used (&, =, %, +, #, space) already passes the WAF in WhereOperators in runs #770–#781. These were the last SQL/XSS-style payloads left in test/.

Testing

  • node --check and eslint on the file: 0 errors. The 3 warnings are on untouched lines 238, 342 and 361.
  • Not run against dev11 (the stack keys are only in GoCD). The next sdk-js-cda-daily-sanity run on this branch will confirm.

🤖 Generated with Claude Code

Error_XSSAttempt_SafelyHandled sends '<script>alert("xss")</script>' as a
where() value. The Cloudflare WAF on dev11 blocks it with an HTML 403
page at random, so the SDK fails with "SyntaxError: Unexpected token '<'"
(passed in #770 and #772-#775, failed in #771 and #776-#781 on the same
commit). Error_SQLInjectionAttempt_SafelyHandled sends
"'; DROP TABLE entries; --", the same string that was blocked in
WhereOperators on Nov 16.

Same approach as 45a5af5: replace both with URL metacharacter values
(&, =, %, +, #, space) that already pass the WAF in WhereOperators and
are what can actually corrupt a query string the SDK builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cs-raj
cs-raj requested a review from a team as a code owner November 23, 2026 14:41
@snyk-io

snyk-io Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@cs-raj
cs-raj merged commit bf91475 into feature/comprehensive-integration-tests Nov 23, 2026
9 checks passed
@cs-raj
cs-raj deleted the fix/waf-blocked-error-handling-payloads branch November 23, 2026 14:44
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