security(cli): warn on --endpoint-url outside trusted vngcloud.vn domain (SEC-08)#24
Closed
vks-team wants to merge 1 commit into
Closed
security(cli): warn on --endpoint-url outside trusted vngcloud.vn domain (SEC-08)#24vks-team wants to merge 1 commit into
vks-team wants to merge 1 commit into
Conversation
…ain (SEC-08) grn authenticates against the real IAM and sends the resulting reusable bearer token to whatever host --endpoint-url names — so a mistyped or malicious host captures a token it can replay against the real API. Unlike AWS SigV4 (signed per request/host), this bearer is replayable. Add cli.IsTrustedEndpoint / WarnIfUntrustedEndpoint and call it from the VKS and vServer client builders: when --endpoint-url resolves to a host outside *.vngcloud.vn, print a stderr warning that a bearer token will be sent there. Warns only; does not block (custom/test endpoints still work). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finding (SEC-08)
grnauthenticates against the real IAM (iamapis.vngcloud.vn, hardcoded) to mint a bearer token, then sends it with every request to whatever--endpoint-urlnames.--endpoint-urlonly changes the VKS/vServer base URL, not IAM — so:The token is a plain bearer (not signed per-request like AWS SigV4), so a host that captures it can replay it against the real API until it expires. Worse combined with
--no-verify-ssl(MITM). Confirmed in code:internal/auth/token.go— IAM URL is hardcoded, unaffected by--endpoint-url.internal/client/client.go—Authorization: Bearerset on every request tobaseURL(=--endpoint-url).Fix (warn, don't block)
Add
cli.IsTrustedEndpoint/cli.WarnIfUntrustedEndpointand call them from the VKS and vServer client builders. When--endpoint-urlresolves to a host outside*.vngcloud.vn, print a stderr warning that a replayable bearer token will be sent there. Does not block — legitimate custom/test endpoints still work (consistent with howawspermits--endpoint-url). Token scoping by host is a server-side concern and out of scope here.Example:
Testing
TestIsTrustedEndpoint: empty/vngcloud.vn/*.vngcloud.vntrusted;attacker.com,evil.vngcloud.vn.attacker.com,localhost, malformed → untrusted.go vet ./...clean; fullgo test ./...passes; build clean.🤖 Generated with Claude Code