Skip to content

Add URL validation to generator URL template output#108

Merged
CharlieTLe merged 1 commit into
CharlieTLe:809from
cortexproject:url-validation-fix
Apr 24, 2026
Merged

Add URL validation to generator URL template output#108
CharlieTLe merged 1 commit into
CharlieTLe:809from
cortexproject:url-validation-fix

Conversation

@friedrichg
Copy link
Copy Markdown

Summary

  • Validate generator URL template output to prevent XSS vectors
  • Scheme must be http or https (blocks javascript: and data: URIs)
  • Host must be present
  • Fragment must not contain < or > characters (blocks script tag injection)
  • Added 5 test cases covering all attack vectors

Test plan

  • javascript: URI rejected
  • data: URI rejected
  • Fragment with <script> tag rejected
  • Missing host rejected
  • Valid URL with clean fragment allowed
  • All existing tests pass

Validate that the output of executeGeneratorURLTemplate produces a safe
URL by checking:
- Scheme must be http or https (blocks javascript: and data: URIs)
- Host must be present
- Fragment must not contain HTML characters < or > (blocks script injection)

Add test cases covering javascript URI, data URI, fragment injection,
missing host, and valid fragment scenarios.

Signed-off-by: Friedrich Gonzalez <charlie_le@apple.com>
Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
@CharlieTLe CharlieTLe merged commit faf65ea into CharlieTLe:809 Apr 24, 2026
3 checks passed
@CharlieTLe CharlieTLe deleted the url-validation-fix branch April 24, 2026 16:25
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