mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-12-10 17:23:04 +03:00
Web Vault: Cache-Control Headers are incorrectly being sent in requests instead of server responses #2264
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Algebro7 on GitHub.
I started playing around with bitwarden_rs today and noticed that
cache-control: no-cache, max-age=0andpragma: no-cacheare being sent in the request headers instead of in the response, so they are effectively doing nothing. Example:I also recommend setting the
no-storedirective in addition tono-cache.Additionally, many responses aren't setting the additional security headers like
X-Frame-OptionsandX-Content-Type-Optionsreferenced in #44 . example from /api/sync:@Algebro7 commented on GitHub:
It is still possible in some browsers (like certain versions of IE) to trigger content sniffing even if the content type is set as application/json. As for cache-control, once again it's true that most browsers won't cache JSON responses, but it's better to just set them and not have to rely on the client.
@Algebro7 commented on GitHub:
I was jumping through the codebase and the only reference I can find to the cache-control headers is here in
web-vault/app/main.5930681efb99dba78a54.jsI could be wrong since the issue doesn't happen with the official bitwarden web vault, but I'm guessing this is an upstream issue with the web-vault that we won't be able to fix.
@dani-garcia commented on GitHub:
I don't know exactly why the web vault is setting those headers in the requests. I haven't noticed the browser caching the server response, so I don't know how useful would adding more headers be.
At the moment, we are only sending the security headers with the web vault resources, the API itself doesn't send them. As far as I know, they don't make sense in the API (the only one who may be interesting is the
X-Content-Type-Options, but we always set the content type in the API requests, so it won't provide any benefit there).@dani-garcia commented on GitHub:
I pushed a new commit adding the headers globally, and also added the cache header following what upstream was doing:
I pushed this to the admin page branch in case there are any incompatibilities or whatever.