Skip to content

Conversation

@phrocker
Copy link
Contributor

  • Implement RDP proxy module with Sentrius integration

* Implement RDP proxy module with Sentrius integration
JwtDecoder compositeJwtDecoder) throws Exception {
http
.securityMatcher("/guacamole/**")
.csrf(csrf -> csrf.disable())

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection High

CSRF vulnerability due to protection being disabled.

Copilot Autofix

AI 3 months ago

To fix the problem, CSRF protection should not be globally disabled for the /guacamole/** endpoints. Simply remove the .csrf(csrf -> csrf.disable()) line from the filter chain in the tunnelChain bean method. CSRF protection will then be active by default, per Spring Security best practices, requiring proper handling of CSRF tokens on these endpoints if accessed by browser clients. No other code changes or imports are needed, unless you decide you need to add configuration to handle CSRF tokens (not requested by the error/fix).

Suggested changeset 1
rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/config/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/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/config/SecurityConfig.java b/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/config/SecurityConfig.java
--- a/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/config/SecurityConfig.java
+++ b/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/config/SecurityConfig.java
@@ -118,7 +118,6 @@
                                     JwtDecoder compositeJwtDecoder) throws Exception {
         http
             .securityMatcher("/guacamole/**")
-            .csrf(csrf -> csrf.disable())
             .requestCache(cache -> cache.disable())
             .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
             .authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
EOF
@@ -118,7 +118,6 @@
JwtDecoder compositeJwtDecoder) throws Exception {
http
.securityMatcher("/guacamole/**")
.csrf(csrf -> csrf.disable())
.requestCache(cache -> cache.disable())
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
Copilot is powered by AI and may make mistakes. Always verify output.
.anyRequest().permitAll())
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.csrf(csrf -> csrf.disable())

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection High

CSRF vulnerability due to protection being disabled.

Copilot Autofix

AI 3 months ago

To address the issue, CSRF protection should be enabled, especially for endpoints accessible by browsers. Therefore, the .csrf(csrf -> csrf.disable()) configuration should be removed. By default, Spring Security enables CSRF protection, so omitting the .csrf() configuration leaves protection on. If there are endpoints (such as /guacamole/websocket) that genuinely require CSRF disabled (e.g., for non-browser WebSocket connections), CSRF protection can be selectively disabled for those endpoints rather than globally. However, based on the provided code, the simplest and best fix is to remove the csrf.disable() call from the SecurityFilterChain bean, thereby restoring default CSRF protection for all routes.

Changes required:

  • Remove (or comment out) the line .csrf(csrf -> csrf.disable()) from the rdpProxySecurityFilterChain configuration in RdpProxySecurityConfig.java.
  • No imports, supporting methods, or further configuration changes are required if we enable default CSRF protection.
Suggested changeset 1
rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/security/RdpProxySecurityConfig.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/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/security/RdpProxySecurityConfig.java b/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/security/RdpProxySecurityConfig.java
--- a/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/security/RdpProxySecurityConfig.java
+++ b/rdp-proxy/src/main/java/io/sentrius/sso/rdpproxy/security/RdpProxySecurityConfig.java
@@ -36,7 +36,6 @@
                 .anyRequest().permitAll())
             .sessionManagement(session -> session
                 .sessionCreationPolicy(SessionCreationPolicy.STATELESS))
-            .csrf(csrf -> csrf.disable())
             .cors(cors -> cors.configurationSource(corsConfigurationSource()))
             .build();
     }
EOF
@@ -36,7 +36,6 @@
.anyRequest().permitAll())
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.csrf(csrf -> csrf.disable())
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.build();
}
Copilot is powered by AI and may make mistakes. Always verify output.
@phrocker phrocker merged commit dbb7153 into main Oct 24, 2025
7 checks passed
phrocker added a commit that referenced this pull request Nov 27, 2025
* Initial plan

* Remove service-specific verbs (Jira and GitHub)

Co-authored-by: phrocker <[email protected]>

* Mark service-specific verbs as not AI-callable instead of removing them

Co-authored-by: phrocker <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: phrocker <[email protected]>
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