Skip to content

codeql: close insecure-trustmanager + unsafe-hostname + url-forward + redos (Task 8) - #45

Merged
natechadwick merged 2 commits into
mainfrom
codeql/trustmanager-forward-redos
Aug 14, 2026
Merged

codeql: close insecure-trustmanager + unsafe-hostname + url-forward + redos (Task 8)#45
natechadwick merged 2 commits into
mainfrom
codeql/trustmanager-forward-redos

Conversation

@natechadwick-intsof

Copy link
Copy Markdown
Collaborator

Summary

Closes 4 CodeQL alerts with real fixes (CodeQL-modeled — no paths-ignore, no sink-line suppressions):

1. java/insecure-trustmanager (#594) + java/unsafe-hostname-verification (#584) — PSSiteImporter

overrideConnectionProperties() previously installed an all-trusting X509TrustManager (accepts any chain) plus an always-true HostnameVerifier. Now:

  • Trust managers come from the JVM default TrustManagerFactory — TLS certificates are validated against the system trust store (cacerts). Operators needing a private CA must keytool -importcert ... -cacerts.
  • The always-true hostname verifier is removed entirely; the JVM default (RFC 2818 host matching) is kept for the duration of the override.

Matches 004 T046 (PR #1297) + T053 (PR #1342).

2. java/unvalidated-url-forward (#568) — PSServletUtils

getDispatcher(path) passed caller-controlled paths straight to getRequestDispatcher. New validateForwardPath() runs before the container call and rejects:

  • control characters (U+0000–U+001F, U+007F) and backslashes
  • .. traversal segments (start/mid/bare/query-string shapes)
  • WEB-INF / META-INF targets (full-segment match, accepts look-alikes like /web-info/notes)

Matches 004 T052 (PR #1335).

3. java/redos (#610) — PSFormEncodeDecodeHelper

fixCommentTags regex had an overlapping alternation (([^\- ]|[\r\n]|-[^\- ])*) that allowed ambiguous splits → exponential backtracking on adversarial input. Fix:

  • 64 KiB input cap (defense-in-depth; far beyond any practical comment-fix workload)
  • collapsed [\r\n] into the [^\- ] class (superset — '\r'/'\n' are neither '-' nor space) → single non-overlapping path per char, linear matching

Matches 004 T049 (PR #1333).

Verification

./mvn-env.sh test -pl projects/sitemanage,modules/extensions-main,modules/servletutils
# Tests run: 309, Failures: 0, Errors: 0, Skipped: 17
# => BUILD SUCCESS

Notes

  • No Maven dependency change; *.version properties untouched.
  • Per AGENTS.md, Version.properties was not modified.

natechadwick-intsof and others added 2 commits August 13, 2026 11:53
…-forward #568 + redos #610 (Task 8)

Real fixes (CodeQL-modeled) for 4 alerts across 3 modules:

1. PSSiteImporter.overrideConnectionProperties (java/insecure-trustmanager
   #594): replaced all-trusting X509TrustManager with JVM default
   TrustManagerFactory managers (validates against cacerts). Also removes
   the always-true HostnameVerifier (java/unsafe-hostname-verification
   #584) - JVM default RFC 2818 host matching is kept. Matches 004 T046
   (PR #1297) + T053 (PR #1342).

2. PSServletUtils.getDispatcher (java/unvalidated-url-forward #568): new
   validateForwardPath() rejects control chars/backslashes, '..'
   traversal segments (incl. query-string/bare shapes), and
   WEB-INF/META-INF targets before getRequestDispatcher. Matches 004
   T052 (PR #1335).

3. PSFormEncodeDecodeHelper.fixCommentTags (java/redos #610): 64 KiB
   input cap + collapsed overlapping [\r\n] alternation into [^\- ]
   class for linear matching. Matches 004 T049 (PR #1333).

Verification: compile + tests pass on all 3 modules (309 tests, 0
failures). No suppressions/paths-ignore needed.

# 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 b7722aab13 codeql: close insecure-trustmanager #594 + unsafe-hostname #584 + url-forward #568 + redos #610 (Task 8)
# No commands remaining.
# You are currently rebasing branch 'codeql/trustmanager-forward-redos' on '76f4ae3e0f'.
#
# Changes to be committed:
#	modified:   CHANGELOG.md
#	modified:   modules/extensions-main/src/main/java/com/percussion/extensions/translations/PSFormEncodeDecodeHelper.java
#	modified:   modules/servletutils/src/main/java/com/percussion/utils/servlet/PSServletUtils.java
#	modified:   projects/sitemanage/src/main/java/com/percussion/sitemanage/importer/PSSiteImporter.java
#
Signed-off-by: Nate Chadwick <natechadwick@users.noreply.github.com>
@natechadwick
natechadwick merged commit 545d1c3 into main Aug 14, 2026
3 checks passed
@natechadwick
natechadwick deleted the codeql/trustmanager-forward-redos branch August 14, 2026 00:57
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