Skip to content

Upgraded libraries recommended by Renovate that it couldnt automatica…#526

Open
scottatwell1 wants to merge 15 commits intomasterfrom
feature/pdda-517
Open

Upgraded libraries recommended by Renovate that it couldnt automatica…#526
scottatwell1 wants to merge 15 commits intomasterfrom
feature/pdda-517

Conversation

@scottatwell1
Copy link
Copy Markdown
Collaborator

…lly apply. Note, due the pmd upgrade a LOT of test classes had to be amended

Before creating a pull request make sure that:

  • commit messages are meaningful and follow good commit message guidelines
  • README and other documentation has been updated / added (if needed)
  • tests have been updated / new tests has been added (if needed)

Please remove this line and everything above and fill the following sections:

JIRA link (if applicable)

Change description

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[ ] No

…lly apply. Note, due the pmd upgrade a LOT of test classes had to be amended
@hmcts-jenkins-cnp hmcts-jenkins-cnp bot requested a deployment to preview June 25, 2025 14:21 Abandoned
…s when getting court sites to exclude obsolete court sites
Comment on lines +106 to +115
return http.securityMatcher("/login/**", "/oauth2/**", "/", "/dashboard/**")
.authorizeHttpRequests(auth -> auth.requestMatchers(AUTH_WHITELIST).permitAll()
.anyRequest().authenticated())
.oauth2Login(
auth -> auth.successHandler(getSuccessHandler()).failureHandler(getFailureHandler())
.authorizationEndpoint(endpoint -> endpoint
.authorizationRequestRepository(cookieAuthorizationRequestRepository())))
.addFilterAfter(new AuthorisationTokenExistenceFilter(),
SecurityContextHolderFilter.class)
.csrf(AbstractHttpConfigurer::disable)

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection High

CSRF vulnerability due to protection being disabled.

Copilot Autofix

AI 9 months ago

To fix the issue, CSRF protection should be enabled for the affected endpoints. This can be achieved by removing the csrf(AbstractHttpConfigurer::disable) line from the authorizationClientSecurityFilterChain method. Additionally, if there are specific endpoints that do not require CSRF protection (e.g., APIs used by non-browser clients), CSRF protection can be selectively disabled for those endpoints using requestMatchers.

Steps to fix:

  1. Remove the csrf(AbstractHttpConfigurer::disable) line from the authorizationClientSecurityFilterChain method.
  2. Ensure CSRF protection is enabled for browser-accessible endpoints.
  3. If necessary, selectively disable CSRF protection for non-browser client endpoints using requestMatchers.

Suggested changeset 1
src/main/java/uk/gov/hmcts/pdm/publicdisplay/manager/web/logon/WebSecurityConfig.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/main/java/uk/gov/hmcts/pdm/publicdisplay/manager/web/logon/WebSecurityConfig.java b/src/main/java/uk/gov/hmcts/pdm/publicdisplay/manager/web/logon/WebSecurityConfig.java
--- a/src/main/java/uk/gov/hmcts/pdm/publicdisplay/manager/web/logon/WebSecurityConfig.java
+++ b/src/main/java/uk/gov/hmcts/pdm/publicdisplay/manager/web/logon/WebSecurityConfig.java
@@ -100,3 +100,3 @@
                 SecurityContextHolderFilter.class)
-            .csrf(AbstractHttpConfigurer::disable)
+            .csrf(Customizer.withDefaults())
             .cors(cors -> cors.configurationSource(request -> getCorsConfiguration())).build();
EOF
@@ -100,3 +100,3 @@
SecurityContextHolderFilter.class)
.csrf(AbstractHttpConfigurer::disable)
.csrf(Customizer.withDefaults())
.cors(cors -> cors.configurationSource(request -> getCorsConfiguration())).build();
Copilot is powered by AI and may make mistakes. Always verify output.
@hmcts-jenkins-cnp hmcts-jenkins-cnp bot requested a deployment to preview July 8, 2025 22:51 Abandoned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants