Repository navigation
Conversation
Device Bound Session Credentials (a W3C WebAppSec editor's draft) let a
server tie a session to a key pair the browser keeps on the device. Wicket
had nothing for it: a session cookie copied by malware works from any
machine until the session ends.
The new wicket-experimental/wicket-dbsc module adds it without touching the
container's session cookie, which lives as long as the HTTP session and
cannot be made short-lived. DeviceBoundSessions.install(application) mounts
a registration and a refresh endpoint and adds a request cycle listener.
DeviceBoundSessions.get().start(), called after sign-in, adds
Secure-Session-Registration to the current response, a redirect included.
Once the browser has registered a key, every request Wicket handles for
the session needs a second, short-lived cookie, scoped to the application's
path, which the browser only gets by signing a server challenge with that
key. A request without it is rejected with 403 through
onMissingCredential(), which an application can override. Enforcement
starts with the first bound cookie the browser presents, or after a grace
period, because the registration races with the requests that follow
sign-in.
Proofs are verified with the JDK alone: ES256 on P-256 and RS256 with at
least 2048 bits. alg none, other JWT types and points off the curve are
refused. The draft puts the JWK in the JWT header while its own example
puts it in the payload, so both are read.
Browsers without DBSC ignore the header and their sessions stay unbound.
Applications that do not install the module see no change. The examples
get a "device bound sessions" application in the authentication index.
The server side was exercised against Jetty over HTTP with a WebCrypto
P-256 key: registration, a replayed session cookie rejected, refresh with
a challenge, a proof from another key refused and a vanished session ended
with {"continue": false}. Chrome 155 on Linux receives the header but does
not register, even with the DBSC developer flags, so a run in a real
browser still needs Chrome on Windows. Chrome and Firefox both keep working
with the example unbound.
GitHub issue #2008
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2008.
What
A new experimental module,
wicket-experimental/wicket-dbsc, that binds a Wicket session to the device it was signed in on, following the Device Bound Session Credentials draft. It also adds a "device bound sessions" example in the authentication index of the examples.How it works
JSESSIONIDis left alone: it lives as long as the HTTP session and cannot be made short-lived. A bound session needs a second cookie as well. That cookie lives 10 minutes by default and is scoped to the application's path (context path plus filter path).installmounts a registration endpoint and a refresh endpoint and adds a request cycle listener.start()sendsSecure-Session-Registrationon the current response, which can be a page, an Ajax response or the redirect after the sign-in form. The registration endpoint verifies the browser's proof, stores the public key in the Wicket session, returns the JSON session instructions and sets the bound cookie.Secure-Session-Challenge. A valid proof gets a new bound cookie. A session that no longer exists gets{"continue": false}.onMissingCredential(). By default that rejects the request with 403 and leaves the session alone. Enforcement starts with the first bound cookie the browser presents, or after a 30-second grace period, because the registration races with the requests that follow sign-in.algnone, other JWT types and points off the curve are refused. The draft puts the JWK in the JWT header (§9.10), but its own example puts it in the payload, so both are read.Testing
mvn clean verify -Pjs-testis green.JSESSIONID, refresh with a challenge, refusal of a proof from another key, and{"continue": false}for a session that is gone.DeviceBoundSessions:RequireOriginTrialTokens/falseand the software-keys flag. A run in a real browser still needs Chrome 146+ on Windows. If someone has one at hand, the example at/devicebounduses a one-minute bound cookie, so refreshes are easy to watch.Open questions
wicket-experimentalthe right home until it settles?provider_*),include_site, and races between cluster nodes during cookie rotation.