Skip to content

fix: guard legacy redirect routes against open-redirect (B8 / J11) - #70

Merged
Chris Ball (ball42) merged 1 commit into
developfrom
fix/j11-b8-open-redirects
Jul 11, 2026
Merged

fix: guard legacy redirect routes against open-redirect (B8 / J11)#70
Chris Ball (ball42) merged 1 commit into
developfrom
fix/j11-b8-open-redirects

Conversation

@ball42

Copy link
Copy Markdown
Collaborator

Closes bug B8 (CodeQL py/url-redirection / open redirect), part of the J11 CodeQL work.

The issue

The legacy /webhooks/* and /cron/* compatibility routes build a 301 redirect by interpolating a user-controlled value (name / target_job / target_webhook) straight into the path: redirect(f"/automations/jamfpro/{name}/edit"). A value like //evil.com or /\evil.com makes the result protocol-relative, so the browser resolves it off-site — an open redirect / phishing vector.

The fix

  • New bin/url_safety.pysafe_path_segment(value): strips / and \ from a single path-segment value (no third-party imports, no cycle risk).
  • All five app.py interpolated redirects sanitize their segment; an empty/all-separator value redirects to the automation list page rather than building a dangling // path.
  • views/template_view.py's /workflows/<path:rest> catch-all guards against backslash / // / scheme tails, falling back to the catalog.
  • tests/test_redirect_safety.py: off-site payloads (//evil.com, /\evil.com, \\evil.com, https://evil.com, ////, /) per route assert the Location is always a local /automations (or /templates) path — never protocol-relative or off-site — plus normal-value happy-path tests. (Verified the tests have teeth: reverting a site to raw fails them.)

J11 scope note

This is the concrete code fix. The remaining J11 work — dispositioning the CodeQL alert queue (the critical SSRF is accepted-by-design; ~19 alerts live in files develop already deleted and auto-resolve at release; give develop a scan baseline) — is deferred to the develop → main release PR, when the true post-merge alert set is visible.

Targets develop for the batched v3.2 release. Full suite green (145 passed), ruff clean.

The legacy /webhooks/* and /cron/* compatibility routes interpolate a
user-controlled value (name/target_job/target_webhook) straight into a
301 redirect path. A value like //evil.com or /\evil.com makes the
result protocol-relative, so the browser resolves it off-site (open
redirect / phishing; CodeQL py/url-redirection).

Add bin/url_safety.safe_path_segment (no third-party imports, no cycle
risk) that strips slashes/backslashes from single-segment names, and
apply it to all five app.py interpolated redirects. The template_view
/workflows/<path:rest> catch-all guards against backslash/'//'/scheme
tails, falling back to the catalog. Tests cover off-site payloads per
route plus the normal-value happy paths.
@ball42
Chris Ball (ball42) merged commit e02ab88 into develop Jul 11, 2026
2 checks passed
@ball42
Chris Ball (ball42) deleted the fix/j11-b8-open-redirects branch July 11, 2026 15:05
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.

1 participant