Skip to content

credentials/alts: preserve boundAccessToken in altsTC.Clone - #9345

Merged
easwars merged 1 commit into
grpc:masterfrom
nileshpatil6:fix/alts-clone-bound-access-token
Aug 21, 2026
Merged

credentials/alts: preserve boundAccessToken in altsTC.Clone#9345
easwars merged 1 commit into
grpc:masterfrom
nileshpatil6:fix/alts-clone-bound-access-token

Conversation

@nileshpatil6

@nileshpatil6 nileshpatil6 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

altsTC.Clone does not copy boundAccessToken, so a cloned ALTS credential silently loses the token and performs its handshake without it.

Detail

boundAccessToken was added to the altsTC struct in 00be1e1, "[alts] Add plumbing for the bound access token field in the ALTS Start". That commit added the field and consumed it in ClientHandshake:

 type altsTC struct {
-	info      *credentials.ProtocolInfo
-	side      core.Side
-	accounts  []string
-	hsAddress string
+	info             *credentials.ProtocolInfo
+	side             core.Side
+	accounts         []string
+	hsAddress        string
+	boundAccessToken string
 }
...
+	opts.BoundAccessToken = g.boundAccessToken

but it did not update Clone, which still copies only the four original fields:

func (g *altsTC) Clone() credentials.TransportCredentials {
	...
	return &altsTC{
		info:      &info,
		side:      g.side,
		hsAddress: g.hsAddress,
		accounts:  accounts,
	}
}

Clone is part of the exported credentials.TransportCredentials interface, and grpc-go calls it internally, for example when building the RLS control channel in balancer/rls/control_channel.go:

credsOpt = grpc.WithTransportCredentials(bOpts.DialCreds.Clone())

so a clone taken there would hand the handshaker an empty BoundAccessToken.

To be upfront about reachability: there is currently no exported setter for boundAccessToken, so today it is only assigned in tests and the field is always empty in production. This is a latent bug in the plumbing rather than one users can hit right now, but it will bite as soon as a setter lands, and Clone dropping a field it should carry is wrong regardless.

Change

One field added to the struct literal in Clone.

Testing

TestCloneClient already asserts on side, hsAddress and accounts, so I extended it to cover boundAccessToken alongside them. Without the fix it fails:

alts_test.go:121: cc.boundAccessToken = "", want "bound-access-token"

With the fix, go test ./credentials/alts/... passes for the whole tree and go vet ./credentials/alts/... is clean.

RELEASE NOTES: none

`boundAccessToken` was added to `altsTC` in 00be1e1 ("[alts] Add
plumbing for the bound access token field in the ALTS Start"), which
also wired it into `ClientHandshake`, but `Clone` was not updated to
copy it. A cloned credential therefore silently loses the token and
performs the handshake without it.

`Clone` is part of the exported `credentials.TransportCredentials`
interface and is called inside grpc-go itself, for example in
`balancer/rls/control_channel.go` where the RLS control channel is
built with `bOpts.DialCreds.Clone()`.

`TestCloneClient` already asserts on `side`, `hsAddress` and `accounts`,
so this extends it to cover `boundAccessToken`. Without the fix it
fails with:

    alts_test.go:121: cc.boundAccessToken = "", want "bound-access-token"
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 20, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: nileshpatil6 / name: nileshpatil6 (cfe9afc)

@nileshpatil6

Copy link
Copy Markdown
Contributor Author

CLA is signed now, and all eight required Testing jobs pass, including -race, arm and i386.

Notes on the three red checks, none of which look related to this change:

Happy to rebase if that would help with any of these.

@eshitachandwani eshitachandwani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding and fixing this.

Adding @easwars for a second review.

@eshitachandwani

Copy link
Copy Markdown
Member

Happy to rebase if that would help with any of these.

This has been fixed, please rebase on master to get it passing.

@matthewstevenson88

Copy link
Copy Markdown
Contributor

@rockspore Can you PTAL?

@rockspore

Copy link
Copy Markdown
Contributor

I think this is fine. Although boundAccessToken has no public use case, it should be preserved in Clone.

@easwars
easwars merged commit 4793ad0 into grpc:master Aug 21, 2026
21 of 26 checks passed
@easwars

easwars commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@nileshpatil6 : Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants