Class BackUrlTokenService
bck_prompt_url).
The back url is a request parameter that ends up in a sendRedirect, so it is a classic open-redirect sink. Instead of relying solely on
SecurityUtil.isInternalRedirectUrlSafe(java.lang.String, javax.servlet.http.HttpServletRequest) (a deny-list whose robustness depends on the deployed core version and configuration), the url is wrapped in a
server-signed token : base64url(url).expiry.hmacSHA256(base64url(url).expiry).
The HMAC is computed with the application crypto key (CryptoService.hmacSHA256(String), key stored in the Datastore, therefore stable across restarts
and shared across cluster nodes). Any value forged or tampered with by a client fails the signature check and is rejected, which closes the open redirect
regardless of the core version. A short time-to-live bounds replay. The decoded url is still passed through SecurityUtil.isInternalRedirectUrlSafe(java.lang.String, javax.servlet.http.HttpServletRequest) as
a second line of defense.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildToken(String strUrl) Build a server-signed token wrapping the given internal url, to be transported as thebck_prompt_urlparameter.static StringverifyToken(String strToken, javax.servlet.http.HttpServletRequest request) Verify a token produced bybuildToken(String)and return the internal url it carries.
-
Method Details
-
buildToken
Build a server-signed token wrapping the given internal url, to be transported as thebck_prompt_urlparameter.- Parameters:
strUrl- the internal url to protect (server-side value)- Returns:
- the signed token, or an empty string if the url is blank
-
verifyToken
Verify a token produced bybuildToken(String)and return the internal url it carries.- Parameters:
strToken- the token read from thebck_prompt_urlrequest parameterrequest- the current request (used for theSecurityUtil.isInternalRedirectUrlSafe(java.lang.String, javax.servlet.http.HttpServletRequest)second check)- Returns:
- the verified internal url, or
nullif the token is missing, malformed, has an invalid signature, is expired or resolves to an unsafe url
-