Repository navigation
Open
Description
Summary
While fixing the Third Party's H2 console in #270, I found that the Authorization Server's and Data Custodian's console settings are unsafe or do nothing. None of this can be exploited today, because no console exists in either module (see 1). It becomes exploitable as soon as someone adds the console dependency to restore it.
Findings
- No module has the H2 console. Spring Boot 4 moved the console's auto-configuration into
org.springframework.boot:spring-boot-h2console. The AS and the DC don't depend on it, so theirspring.h2.console.*settings do nothing since the Boot 4 migration. fix(thirdparty): address the #268 review of Third Party form login (#249) #270 adds it to the Third Party only. - AS
localallows remote access:openespi-authserver/src/main/resources/application-local.ymlsetsspring.h2.console.web-allow-others: true. Once the console exists, any machine that can reach the AS's port can open it. The console runs any SQL, and H2'sCREATE ALIASruns Java code. The AS database also holds the OAuth client secrets, authorizations and tokens. - AS has no rule for
/h2-console. Whatever the AS's default rule allows applies to it, and nothing exempts it from CSRF, which the console needs to work. - DC allows it with no sign-in:
openespi-datacustodian/.../config/SecurityConfiguration.javalists/h2-console/**underpermitAll(). DClocalsetsweb-allow-others: false(localhost only), which is good. But with no sign-in required, any web page open in the developer's browser could send requests tolocalhostand reach the console.
Proposed fix
Follow the Third Party's final design from #270 in each module that keeps a console:
- A development-only chain: a configuration with its own filter chain for
/h2-console/**, loaded only whenspring.h2.console.enabled=true. The module's main chain denies/h2-console/**(the DC'spermitAll()goes), so the console stays shut in every other profile. - In that chain:
- Require a signed-in administrator (DC:
ROLE_CUSTODIANfrom the form-login session; AS: its admin login). - Require that requests come from the console itself, as the TP's
SameOriginFetchAuthorizationManagerdoes (it could move to a shared module). The entry page (a parameterless GET) may beSec-Fetch-Site: same-originornone. Every other request must besame-originand carry aRefererfrom a console page. - Save only the entry page for the redirect back after sign-in, with no
?continuemarker. - Turn off CSRF tokens for the console only, send anonymous users to the login page, and allow same-origin frames.
- Build the path from
spring.h2.console.pathwith trailing slashes removed./h2-console/+/**would match nothing. - Why all of this: session cookies don't stop other pages, because every
localhostport is the same site, soSameSite=Laxstill sends the cookie from a page on another local port.Sec-Fetch-Sitealone doesn't stop the sign-in redirect either, because the redirect after the login POST arrives assame-origin. Unchecked, an attacker's console action could be saved as the interrupted request, or passed as areturn_to, and run after sign-in. All of this was verified in Chrome on the TP in fix(thirdparty): address the #268 review of Third Party form login (#249) #270.
- Require a signed-in administrator (DC:
web-allow-others: falseon every profile that enables the console (fix the AS'slocal).server.servlet.session.cookie.same-site: laxon every profile. Notstrict, because cross-site redirects in the OAuth flow must carry the session.- Add
spring-boot-h2console(runtime) only if developers want the console in that module. Otherwise remove the deadspring.h2.console.*settings. - Tests like the TP's
H2ConsoleSecurityTest(console enabled) and the console-disabled check inFormLoginTest.
References
- Third Party setup and its local verification: fix(thirdparty): address the #268 review of Third Party form login (#249) #270
- Spring Boot 4.0 reference, "Using H2's Web Console": the console is auto-configured when
spring-boot-h2consoleis on the classpath.
Metadata
Metadata
Assignees
Labels
No labels
Activity