Skip to content

[PRM-712] Upgraded re-registration-service dependencies#294

Open
AndyFlintAnswerDigital wants to merge 17 commits intomainfrom
PRM-712
Open

[PRM-712] Upgraded re-registration-service dependencies#294
AndyFlintAnswerDigital wants to merge 17 commits intomainfrom
PRM-712

Conversation

@AndyFlintAnswerDigital
Copy link
Contributor

No description provided.

@AndyFlintAnswerDigital AndyFlintAnswerDigital requested a review from a team as a code owner March 16, 2026 21:23
Comment on lines +98 to +99
http
.csrf(AbstractHttpConfigurer::disable)

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection High

CSRF vulnerability due to protection being disabled.

Copilot Autofix

AI 4 days ago

In general, the fix is to avoid globally disabling CSRF. Instead, either (a) keep CSRF enabled (Spring’s default) and ensure state-changing requests from browsers use CSRF tokens, or (b) if the service really is stateless and only used by non-browser clients, explicitly document and constrain that, and selectively disable CSRF only for those endpoints or authentication mechanisms where it is safe.

For this specific code, the minimal, functionality-preserving change is to remove the explicit .csrf(AbstractHttpConfigurer::disable) call and allow Spring Security’s default CSRF configuration. This will re-enable CSRF protection. Because the code uses SessionCreationPolicy.STATELESS and HTTP Basic, re-enabling CSRF might block unsafe HTTP methods if used from a browser without CSRF tokens; however, that is precisely the protection we want if browsers are clients. Since we must not assume any framework changes elsewhere, the safest change inside this file is simply to delete the disabling call and leave the rest of the chain intact. No additional imports or methods are required.

Concretely:

  • Edit securityFilterChain in SecurityConfig.java.
  • Remove the line .csrf(AbstractHttpConfigurer::disable) from the http configuration chain.
  • Keep session management, HTTP Basic, and authorization rules unchanged.
Suggested changeset 1
services/pds-adaptor/src/main/java/uk/nhs/prm/deductions/pdsadaptor/configuration/SecurityConfig.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/services/pds-adaptor/src/main/java/uk/nhs/prm/deductions/pdsadaptor/configuration/SecurityConfig.java b/services/pds-adaptor/src/main/java/uk/nhs/prm/deductions/pdsadaptor/configuration/SecurityConfig.java
--- a/services/pds-adaptor/src/main/java/uk/nhs/prm/deductions/pdsadaptor/configuration/SecurityConfig.java
+++ b/services/pds-adaptor/src/main/java/uk/nhs/prm/deductions/pdsadaptor/configuration/SecurityConfig.java
@@ -96,7 +96,6 @@
     @Bean
     public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
         http
-            .csrf(AbstractHttpConfigurer::disable)
             .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
             .httpBasic(Customizer.withDefaults())
             .authorizeHttpRequests(auth -> auth
EOF
@@ -96,7 +96,6 @@
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.httpBasic(Customizer.withDefaults())
.authorizeHttpRequests(auth -> auth
Copilot is powered by AI and may make mistakes. Always verify output.
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