Fix XSS vulnerability in SetAttribute (#12) #32

Merged
Claude merged 1 commits from fix/escape-javascript-xss into main 2026-02-15 16:18:36 +00:00
Collaborator

Summary

  • Replace string interpolation in SetAttribute with Playwright's Evaluate argument passing, structurally eliminating the XSS injection surface
  • Remove vulnerable escapeJavaScript helper which only escaped \ and ', missing ", backticks, newlines, null bytes, and unicode separators
  • Values are now safely passed as JavaScript arguments rather than interpolated into the expression string

Test plan

  • go build ./... passes
  • go test ./... passes
  • Manual verification: call SetAttribute with malicious payloads (e.g., '); alert('xss or backtick injection) and confirm they are set literally as attribute values

Closes #12
Parent: #31 (Phase 1, PR 1)

🤖 Generated with Claude Code

## Summary - Replace string interpolation in `SetAttribute` with Playwright's `Evaluate` argument passing, structurally eliminating the XSS injection surface - Remove vulnerable `escapeJavaScript` helper which only escaped `\` and `'`, missing `"`, backticks, newlines, null bytes, and unicode separators - Values are now safely passed as JavaScript arguments rather than interpolated into the expression string ## Test plan - [x] `go build ./...` passes - [x] `go test ./...` passes - [ ] Manual verification: call `SetAttribute` with malicious payloads (e.g., `'); alert('xss` or backtick injection) and confirm they are set literally as attribute values Closes #12 **Parent:** #31 (Phase 1, PR 1) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-02-15 16:13:00 +00:00
fix: eliminate XSS vulnerability in SetAttribute by using Playwright arg passing
All checks were successful
CI / build (pull_request) Successful in 47s
CI / test (pull_request) Successful in 48s
CI / vet (pull_request) Successful in 1m1s
6e94bfe10f
Replace string interpolation in SetAttribute with Playwright's Evaluate
argument passing mechanism. This structurally eliminates the injection
surface — arbitrary name/value strings are safely passed as JavaScript
arguments rather than interpolated into the expression string.

The vulnerable escapeJavaScript helper (which only escaped \ and ') is
removed since it is no longer needed.

Closes #12

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude merged commit 2af4cbcdce into main 2026-02-15 16:18:36 +00:00
Claude deleted branch fix/escape-javascript-xss 2026-02-15 16:18:37 +00:00
Sign in to join this conversation.