Repository navigation
[mesheryctl-axi] Require HTTPS for non-loopback endpoints before sending auth cookies - #90
Conversation
…ing auth cookies Signed-off-by: RameshwariS <shrutisatpute1112@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 48 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Signed-off-by: RameshwariS <152020696+RameshwariS@users.noreply.github.com>
Signed-off-by: RameshwariS <shrutisatpute1112@gmail.com>
Signed-off-by: RameshwariS <shrutisatpute1112@gmail.com>
The previous inline loopback check accepted the trailing-dot root form localhost.; the new isLoopbackHost helper dropped it. Keep accepting it and cover it in the test list. Signed-off-by: ritzorama <ritzorama@users.noreply.github.com>
ritzorama
left a comment
There was a problem hiding this comment.
Nice work - this closes the credential-leak hole in #88 cleanly.
What I verified:
- The guard is in the right place: every authenticated call goes through serverRequestJson, and the check runs before buildUrl, so a bad endpoint now gets the readable VALIDATION_ERROR instead of a TypeError.
- Lookalike hosts (localhost.com, 127.0.0.1.evil.com) are rejected on the parsed hostname, not a string prefix - that was the subtle part, and the tests pin it down.
- Anonymous requests still go through with no cookie, and loopback HTTP plus any HTTPS endpoint keep working.
- Local verification on the current head: format-check, lint, tsc build, and the full suite (212 passed) are all green.
Two small fixes I pushed to the branch:
- Import order for the repo prettier setup (you had already fixed most of it in 7debb3c).
- Kept accepting the trailing-dot root form localhost., which the old inline check accepted - added it to the test list so it stays covered.
CI is re-running on the latest push; once it is green this is good to merge.
|
Thanks! @ritzorama |
Notes for Reviewers
Problem
serverGetJsonsent thetokenandmeshery-providercookies to any configured endpoint, including a plainhttp://URL on a remote host. That exposes the Meshery token in cleartext on the network (CWE-319).Change
src/server.ts: before theCookieheader is built,assertSecureEndpoint()checks the endpoint:https://: allowed for any host (no change)http://to a loopback host (localhost,127.0.0.0/8,::1): allowed, so local Meshery deployments keep workingVALIDATION_ERRORbefore any request is sentisLoopbackHost()matches on the parsed hostname, not a string prefix, so lookalikes such aslocalhost.comor127.0.0.1.evil.comare rejected./api/system/versionprobe) send no cookies and are not checked.All authenticated API callers go through this helper, so
design,model,componentandconnectionare covered.Behaviour change
Users whose mesheryctl context points at a remote
http://endpoint now get an error instead of a silent credential leak. They need to switch the context tohttps://. This should go out with theminorlabel.Testing
test/server-security.test.ts(25 tests): lookalike and remote HTTP hosts are rejected and the fetcher is never called; loopback HTTP and HTTPS hosts still receive the cookie; anonymous remote HTTP requests succeed with no cookie.make build testspasses.Manual check:
connection listagainst a local listener bound to a LAN IP.Before (listener receives the token):
COOKIE: token=FAKE-SECRET-TOKEN-123; meshery-provider=Meshery
After:
error: "Refusing to send Meshery credentials over cleartext http://172.20.10.3:9999"
code: VALIDATION_ERROR
help[2]:
Point the mesheryctl context at an https:// endpoint
Or use a loopback endpoint (localhost / 127.0.0.1) for a local Meshery
With
http://localhost:9999the command still succeeds.Signed commits
Summary by CodeRabbit