Skip to content

fix(java-spring): resolve CodeQL regex and redirect findings#118

Merged
cbullinger merged 1 commit into
mainfrom
fix/codeql-java-spring
Jun 8, 2026
Merged

fix(java-spring): resolve CodeQL regex and redirect findings#118
cbullinger merged 1 commit into
mainfrom
fix/codeql-java-spring

Conversation

@cbullinger

Copy link
Copy Markdown
Collaborator

Summary

Resolves 2 open CodeQL error findings in the Java Spring MFlix server by hardening genre regex filtering and trailing-slash redirects.

Changes

  • Regex injection (MovieServiceImpl): wrap user-supplied genre with Pattern.quote() before case-insensitive matching
  • Unvalidated URL redirection (WebMvcConfig): validate redirect path/query before setting the Location header (reject //, ://, backslashes, null bytes, CRLF)

Testing

Related

Made with Cursor

Escape user-supplied genre values before regex compilation and validate
trailing-slash redirect targets to prevent open-redirect patterns.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Remediates two CodeQL findings in the Java Spring MFlix server by (1) hardening genre filtering against regex injection and (2) preventing unvalidated redirects in the trailing-slash redirect filter.

Changes:

  • Escape user-provided genre with Pattern.quote() before compiling a case-insensitive regex.
  • Validate redirect path and query string before writing the Location header for 308 redirects.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
mflix/server/java-spring/src/main/java/com/mongodb/samplemflix/service/MovieServiceImpl.java Quotes user-supplied genre input to prevent regex injection in Mongo regex criteria.
mflix/server/java-spring/src/main/java/com/mongodb/samplemflix/config/WebMvcConfig.java Adds path/query validation to trailing-slash redirects to mitigate open-redirect / header-injection vectors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dacharyc dacharyc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@cbullinger cbullinger merged commit 5e93708 into main Jun 8, 2026
7 checks passed
@cbullinger cbullinger deleted the fix/codeql-java-spring branch June 8, 2026 11:12
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.

3 participants