This directory implements the DBSC protocol, as described in https://github.com/w3c/webappsec-dbsc/blob/main/README.md.
On an outgoing HTTP request, the URLRequestHttpJob checks SessionService::ShouldDefer to understand whether the request should be deferred while we perform a DBSC refresh. Within //net/device_bound_sessions, we wrap the request in DbscRequest to ensure certain normalization for WebSockets is performed on the URLs involved. ShouldDefer is implemented by SessionServiceImpl, which looks at each Session object associated with the request's site and checks:
CookieCraving). In this case, the request is deferred while a blocking refresh happens.Both proactive and blocking refreshes are handled by the RegistrationFetcher, so named because it also handles new DBSC session registration (covered later). This class is responsible for setting up an HTTP request with the appropriate headers for either registration or refresh. Most importantly, we sign the most recently-provided DBSC challenge with the session's key and include that on the Secure-Session-Response header.
When a refresh is completed, the SessionServiceImpl is notified. Requests deferred for a blocking refresh are now allowed to be resumed. The SessionServiceImpl will also notify any observers about session activity with a SessionAccess. In Chrome, this is used to track which site data is being used on a given tab. We also notify observers with SessionEvent structs containing various Display classes such as SessionDisplay. This is primarily used for DevTools.
After an HTTP request is completed, the URLRequestHttpJob again checks in with the SessionService to handle any DBSC headers on the response - in particular, the Secure-Session-Registration header, which triggers new session registration, and the Secure-Session-Challenge header, which sets the challenge for an existing session.
Any usage of DBSC is noted on the URLRequest in device_bound_session_usage_. This includes DevTools data and Use Counters.
Session data is stored on disk through the SessionStoreImpl, using a SQL database that maps site to the protobuf message SiteSessions in //net/device_bound_sessions/proto/storage.proto. Note that the wrapped_key field is not restored immediately to avoid significant load on the TPM at startup. This requires additional complexity in the SessionServiceImpl to restore keys on-demand before using them.
The DBSC spec leaves some decisions up to the user agent. In particular, Chrome makes two decisions for the overall stability of the system:
SessionServiceImpl::signing_times_, and quota is checked by SessionServiceImpl::SigningQuotaExceeded.SessionServiceImpl::MaybeStartProactiveRefresh.