-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Add RFC 6761–compliant localhost loopback checks so secure
cookies work on localhost (fixes: #1676)
#4038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add RFC 6761–compliant localhost loopback checks so secure
cookies work on localhost (fixes: #1676)
#4038
Conversation
@sreelakshmi-bruno - Any chancel to get this merged in? |
This will be merged and will be included in the upcoming release which will likely go out on coming Tuesday. |
Apologies, we've postponed the release for this PR to April. Thank you for your patience! |
@Chriss4123 I see that your PR on Do you think we can just get straight to upgrading |
Yes, that should work. Just keep in mind tough-cookie has been converted to TypeScript a while ago, however you are using an old version which still uses vanilla JS. |
Since |
fd73bdc
to
b198afb
Compare
Moved the util to |
@ramki-bruno I'd like to keep the |
b198afb
to
88d943f
Compare
88d943f
to
60f88a2
Compare
60f88a2
to
2c3d2ff
Compare
Please use Merge commit |
fixes: #1676
Jira: https://usebruno.atlassian.net/browse/BRU-859
Description
Contribution Checklist:
This commit extends how cookies are treated in secure contexts by fully recognizing
localhost
and loopback IPs as trustworthy origins, matching the de facto behavior of all modern browsers and RFC 6761. Previously,tough-cookie
defaultedsecure
totrue
only forhttps:
andwss:
URLs, causing cookies withsecure
set to never be sent tolocalhost
.What Changed
New
trustworthy-util.js
isPotentiallyTrustworthy(url)
by checking:https
,wss
,file
127.0.0.1/8
and::1
localhost
and*.localhost
IsLocalhost
,IsLoopback
andHostNoBracketsPiece
, located at:IsLocalhost
IsLoopback
HostNoBracketsPiece
cookies.js
Update{ secure: isPotentiallyTrustworthy(url) }
option tocookieJar.getCookiesSync()
.tough-cookie
’s built-in:tough-cookie
does by default—plus treat localhost/loopback the same as modern browsers. No existing functionality is removed, only expanded.Testing this change
secure
cookie would not be sent to/getcookie
after it was set by/setcookie
due tosecure
being set toTrue
.secure
cookie would be sent to/getcookie
which mirrors the behavior of modern browsers.All modern browsers (Chrome et al.) and many other API testing clients (Postman et al.) handle
http://localhost
as a trustworthy origin. It only makes sense that this behavior also exists in Bruno.