Skip to content

codeql: close java/unvalidated-url-redirection #596-#601 (Task 8) - #46

Merged
natechadwick-intsof merged 2 commits into
mainfrom
codeql/url-redirection
Aug 15, 2026
Merged

codeql: close java/unvalidated-url-redirection #596-#601 (Task 8)#46
natechadwick-intsof merged 2 commits into
mainfrom
codeql/url-redirection

Conversation

@natechadwick-intsof

Copy link
Copy Markdown
Collaborator

Summary

Closes 6 CodeQL java/unvalidated-url-redirection alerts (#596-#601) with real fixes (CodeQL-modeled — no paths-ignore, no sink-line suppressions).

New shared validator: PSRedirectValidation

Port of the 004 T051 validator (PR #1344) into modules/perc-security-utils:

  • validateRedirectUrl(url, allowedDomains) — whitelist-based (rejects protocol-relative, data:, javascript:, traversal, non-whitelisted hosts)
  • validateInternalRedirectUrl(url) — path-only (rejects all absolute URLs)
  • createDefaultWhitelist(domain) — domain + www variant

JUnit 4 port of the 004 test suite — 33 tests, all pass.

Sinks fixed

Alert File Fix
#599, #600 PSSecurityFilter.handleFormAuth redirects route through sendValidatedRedirect — relative paths internal-only; absolute URLs validated against publicCmsHostname whitelist (fallback: server name after isValidHostHeader)
#601 PSSecurityFilter HTTPS upgrade prefers configured publicCmsHostname over Host header; validated redirect
#596, #597 PSCommentsRestService seeOther from Referer reduced to same-document relative path (toRelativeRedirectTarget) + validateInternalRedirectUrl; invalid targets → 204
#598 PSUncaughtError error redirect no longer rebuilt from Referer host; always local {contextPath}/error.html validated

Also adds sanitizeForLog (control-char strip) to PSSecurityFilter and PSCommentsRestService for log-injection hygiene, and the perc-security-utils dependency to the comments module pom (same convention as common module).

Verification

./mvn-env.sh test -pl modules/perc-security-utils,deliverytiersuite/delivery-tier-suite/common,deliverytiersuite/delivery-tier-suite/comments
# PSRedirectValidationTest: 33 tests pass
# perc-security-utils total: 109 tests, 0 failures
# => BUILD SUCCESS

Notes

  • PSRedirectValidation adapted to the javax stack (004 uses jakarta) and JUnit 4 (module has no JUnit 5).
  • No Maven dependency change beyond the comments module gaining the existing perc-security-utils dependency.
  • Per AGENTS.md, Version.properties was not modified.

Real fixes (CodeQL-modeled) for 6 alerts + new shared validator:

1. New PSRedirectValidation helper in perc-security-utils - port of
   004 T051 (PR #1344): validateRedirectUrl (whitelist),
   validateInternalRedirectUrl (path-only), createDefaultWhitelist.
   JUnit 4 port of 004 test suite (33 tests).

2. PSSecurityFilter (#599 #600 #601): HTTPS-upgrade + form-auth
   redirects route through sendValidatedRedirect - relative paths
   internal-only; absolute URLs validated against publicCmsHostname
   whitelist (fallback server name after isValidHostHeader). HTTPS
   upgrade prefers configured publicCmsHostname over Host header.
   sanitizeForLog strips control chars.

3. PSCommentsRestService (#596 #597): seeOther from Referer reduced to
   same-document relative path via toRelativeRedirectTarget +
   validateInternalRedirectUrl; invalid targets -> 204. sanitizeForLog
   added. comments pom gains perc-security-utils dep.

4. PSUncaughtError (#598): error redirect no longer rebuilt from
   Referer host; always local {contextPath}/error.html validated.

Verification: compile + tests pass (109 perc-security-utils tests incl.
33 PSRedirectValidationTest; comments/common BUILD SUCCESS).

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# interactive rebase in progress; onto 76f4ae3
# Last command done (1 command done):
#    pick dae8bebcab codeql: close java/unvalidated-url-redirection #596-#601 (Task 8)
# No commands remaining.
# You are currently rebasing branch 'codeql/url-redirection' on '76f4ae3e0f'.
#
# Changes to be committed:
#	modified:   CHANGELOG.md
#	modified:   deliverytiersuite/delivery-tier-suite/comments/pom.xml
#	modified:   deliverytiersuite/delivery-tier-suite/comments/src/main/java/com/percussion/delivery/comments/services/PSCommentsRestService.java
#	modified:   deliverytiersuite/delivery-tier-suite/common/src/main/java/com/percussion/delivery/exceptions/PSUncaughtError.java
#	new file:   modules/perc-security-utils/src/main/java/com/percussion/security/utils/PSRedirectValidation.java
#	new file:   modules/perc-security-utils/src/test/java/com/percussion/security/utils/PSRedirectValidationTest.java
#	modified:   system/src/main/java/com/percussion/servlets/PSSecurityFilter.java
#
Comment thread system/src/main/java/com/percussion/servlets/PSSecurityFilter.java Fixed
Address CodeQL review comments on PR #46 (#701/#702): reconstruct
seeOther/sendRedirect targets from validated URI components and document
the GHAS-unmodelable residual.

> Co-Authored by Grok 4.6 using grok-4.6 with agent Grok 4.6.
@natechadwick-intsof
natechadwick-intsof merged commit 78d1b68 into main Aug 15, 2026
3 checks passed
@natechadwick-intsof
natechadwick-intsof deleted the codeql/url-redirection branch August 15, 2026 00:23
@natechadwick-intsof

Copy link
Copy Markdown
Collaborator Author

Superseded by #50 (consolidated onto current main so the CHANGELOG.md / codeql-config.yml / suppressions.md conflicts no longer block merge). Closing this PR.

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