Skip to content

fix acl relay issue#127

Merged
aojea merged 2 commits into
google:mainfrom
aojea:autopudate
Jun 21, 2026
Merged

fix acl relay issue#127
aojea merged 2 commits into
google:mainfrom
aojea:autopudate

Conversation

@aojea

@aojea aojea commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the relay Access Control List (ACL) in cmd/sam-hub/main.go to check the destination peer's authentication status instead of the source peer's, and introduces new unit tests in cmd/sam-hub/relay_acl_test.go. The feedback highlights a security concern where checking only the destination peer allows unauthenticated source peers to connect, bypassing security controls. It is recommended to require authentication for both the source and destination peers, and to update the unit tests to reflect this dual-authentication requirement.

Comment thread cmd/sam-hub/main.go

func (a *relayACL) AllowConnect(src peer.ID, srcAddr multiaddr.Multiaddr, dest peer.ID) bool {
_, ok := a.hub.authenticatedPeers.Load(src)
_, ok := a.hub.authenticatedPeers.Load(dest)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-high high

Checking only the destination (dest) peer for authentication allows any unauthenticated peer (src) to connect to authenticated peers via the relay. This bypasses the hub's authentication and authorization controls for the initiating peer. To maintain a secure, zero-trust mesh, the relay should verify that both the source and destination peers are authenticated.

	_, srcOk := a.hub.authenticatedPeers.Load(src)
	_, destOk := a.hub.authenticatedPeers.Load(dest)
	ok := srcOk && destOk

Comment on lines +43 to +48
// Dest is authenticated, src is not -> should succeed
hub.authenticatedPeers.Delete(srcPeer)
hub.authenticatedPeers.Store(destPeer, true)
if !acl.AllowConnect(srcPeer, srcAddr, destPeer) {
t.Errorf("Expected AllowConnect to return true when dest is authenticated")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Update the test assertions to verify that connections are only allowed when both the source and destination peers are authenticated.

Suggested change
// Dest is authenticated, src is not -> should succeed
hub.authenticatedPeers.Delete(srcPeer)
hub.authenticatedPeers.Store(destPeer, true)
if !acl.AllowConnect(srcPeer, srcAddr, destPeer) {
t.Errorf("Expected AllowConnect to return true when dest is authenticated")
}
// Dest is authenticated, src is not -> should fail
hub.authenticatedPeers.Delete(srcPeer)
hub.authenticatedPeers.Store(destPeer, true)
if acl.AllowConnect(srcPeer, srcAddr, destPeer) {
t.Errorf("Expected AllowConnect to return false when src is not authenticated, even if dest is")
}
// Both are authenticated -> should succeed
hub.authenticatedPeers.Store(srcPeer, true)
if !acl.AllowConnect(srcPeer, srcAddr, destPeer) {
t.Errorf("Expected AllowConnect to return true when both src and dest are authenticated")
}

@aojea aojea merged commit 8ea4b1f into google:main Jun 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant