The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Do not share through a sign-in to a different service than the one named
Claude456873f575c7
diff --git a/cli/beacon/internal/account/share.go b/cli/beacon/internal/account/share.goindex 129d1aef..9efaef0c 100644--- a/cli/beacon/internal/account/share.go+++ b/cli/beacon/internal/account/share.go@@ -121,6 +121,10 @@ func ResolveShareCredential(opts ResolveShareCredentialOptions) (ShareCredentialloginErr = errors.New("Beacon sign-in expired: run `beacon login` again")case !hasScope(session.Scopes, ScopeTracesWrite):loginErr = ErrTracesWriteScope+ case explicitShareTarget(opts) != "" && !sameBaseURL(explicitShareTarget(opts), session.BaseURL):+ // The sign-in belongs to another service than the one named. Sending the trace to the+ // sign-in's service instead would publish it somewhere the person did not ask for.+ loginErr = fmt.Errorf("signed in to %s, not %s: run `beacon login --auth-url %s`, or pass an API key for it", strings.TrimRight(session.BaseURL, "/"), explicitShareTarget(opts), explicitShareTarget(opts))default:return ShareCredential{BaseURL: strings.TrimRight(session.BaseURL, "/"), Token: session.AccessToken, Source: CredentialSourceLogin, User: session.User}, nil}@@ -132,6 +136,20 @@ func ResolveShareCredential(opts ResolveShareCredentialOptions) (ShareCredentialreturn ShareCredential{}, loginErr}+// explicitShareTarget is the service named by --auth-url or BEACON_AUTH_URL, or "" when neither is+// set and the default applies.+func explicitShareTarget(opts ResolveShareCredentialOptions) string {+ value := strings.TrimSpace(opts.BaseURL)+ if value == "" && opts.Getenv != nil {+ value = strings.TrimSpace(opts.Getenv(BaseURLEnv))+ }+ return strings.TrimRight(value, "/")+}++func sameBaseURL(a, b string) bool {+ return strings.EqualFold(strings.TrimRight(strings.TrimSpace(a), "/"), strings.TrimRight(strings.TrimSpace(b), "/"))+}+func apiKeyCredential(key, baseURL, source, origin string) (ShareCredential, error) {if !strings.HasPrefix(key, APIKeyPrefix) || len(key) == len(APIKeyPrefix) || strings.ContainsAny(key, " \t\r\n") {// The value is deliberately not echoed: it may be a secret pasted into the wrong flag.diff --git a/cli/beacon/internal/account/share_test.go b/cli/beacon/internal/account/share_test.goindex 6b125647..4112d565 100644--- a/cli/beacon/internal/account/share_test.go+++ b/cli/beacon/internal/account/share_test.go@@ -54,6 +54,15 @@ func TestResolveShareCredentialPrecedence(t *testing.T) {{"expired login", ResolveShareCredentialOptions{Load: load(expired, nil)}, "", nil, "expired"},{"nothing", ResolveShareCredentialOptions{Load: load(nil, ErrNotSignedIn)}, "", ErrNoShareCredential, ""},{"bad key", ResolveShareCredentialOptions{Key: "sk-something", Load: load(good, nil)}, "", nil, "not a Beacon API key"},+ {"login for the named service", ResolveShareCredentialOptions{BaseURL: "https://beacon.sh/", Load: load(good, nil)}, CredentialSourceLogin, nil, ""},+ {"login for another service is not used", ResolveShareCredentialOptions{BaseURL: "https://staging.beacon.sh", Load: load(good, nil)}, "", nil, "signed in to https://beacon.sh, not https://staging.beacon.sh"},+ {"env key for another service", ResolveShareCredentialOptions{BaseURL: "https://staging.beacon.sh", Load: load(good, nil), Getenv: env("bcn_api_env")}, CredentialSourceEnv, nil, ""},+ {"service named by the environment", ResolveShareCredentialOptions{Load: load(good, nil), Getenv: func(name string) string {+ if name == BaseURLEnv {+ return "https://staging.beacon.sh"+ }+ return ""+ }}, "", nil, "not https://staging.beacon.sh"},}for _, tc := range cases {t.Run(tc.name, func(t *testing.T) {