This repository contains a complete implementation of the Device Bound Session Credentials (DBSC) protocol, which is a new web authentication mechanism that enhances security by cryptographically binding session credentials to specific devices.
DBSC is a browser feature currently in development by Google Chrome that:
- Creates cryptographic keys in the device's secure hardware (TPM)
- Signs authentication challenges from servers using these device-bound keys
- Automatically refreshes short-lived cookies without user interaction
- Prevents stolen session cookies from being used on other devices
This technology significantly improves web security by mitigating session hijacking attacks, even if attackers manage to steal session cookies or tokens.
- Complete server-side implementation in Go
- Client-side simulation of DBSC functionality with JavaScript
- Display of the authentication flow in the main application
- Working login system with username/password authentication
- Session management with automatic refreshing
- Comprehensive documentation of the DBSC protocol
- Go 1.17 or later
- Chrome Canary 136.0.7059.0 or later (for native DBSC support)
-
Clone this repository:
git clone https://github.com/kokukuma/dbsc-example.git cd dbsc-example -
Install dependencies:
go mod download -
Build and run the server:
go run cmd/server/server.go
IMPORTANT: DBSC requires HTTPS to function properly. For local testing, use an HTTPS tunnel (like ngrok) or set up a local HTTPS certificate.
For the full DBSC experience in Chrome Canary:
- Open Chrome Canary 136.0.7059.0 or later
- Enable the following flags in
chrome://flags:#enable-bound-session-credentials-software-keys-for-manual-testing#enable-standard-device-bound-session-credentials#enable-standard-device-bound-session-persistence
- Restart Chrome Canary
- Visit the application via HTTPS (e.g., using ngrok)
For browsers without native DBSC support, the application includes a JavaScript simulation that demonstrates how DBSC works.
Since DBSC requires HTTPS, you can use ngrok for local testing:
- Install ngrok
- Start your local server:
go run cmd/server/server.go - In another terminal, create an HTTPS tunnel:
ngrok http 8080 - Use the HTTPS URL provided by ngrok to access the application
The demo application includes:
- Homepage with login: A standard login form with username/password authentication.
- Client-side DBSC library: A fully-functional JavaScript implementation of DBSC.
For demo purposes, use the following credentials:
- Username:
dbsc-user - Password:
password
See DBSC.md for a complete explanation of the DBSC protocol and its security benefits.
cmd/server/server.go- Main server applicationcmd/client/- Client-side web applicationlogin.html- Login pageindex.html- Homepage
internal/server/- Core server functionalityinternal/dbsc/- DBSC implementationprotocol.go- DBSC protocol and data structuresauth.go- Session management and authenticationjwt.go- JWT token handlinghandlers.go- HTTP handlers for DBSC endpointslogging.go- DBSC-specific logging
This implementation includes security best practices:
- DBSC requires HTTPS for all communications
- Device-bound sessions last 7 days, but auth cookies expire after 10 minutes
- HTTP-only, Secure cookies with proper SameSite attributes are used
- Challenges are never reused and expire after 5 minutes
- All cryptographic operations use secure, standard algorithms
This project is licensed under the MIT License - see the LICENSE file for details.