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
CleanPart now returns "" when the value still contains a / after trimming.
Deep0702031eb95c8382ba
diff --git a/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go b/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.goindex 8cee5eab..847ccfa5 100644--- a/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go+++ b/cli/beacon-hooks/internal/cloudshuttle/shuttle_test.go@@ -403,6 +403,18 @@ func TestUploadReusesLastObjectForSameRun(t *testing.T) {}}+func TestObjectNameStaysUnderPrefix(t *testing.T) {+ when := time.Date(2026, 7, 12, 16, 17, 3, 0, time.UTC)+ restore := stubNow(t, when)+ defer restore()++ got := ObjectName(Config{Prefix: "tenant/logs", Provider: "claude_code_web", RunID: "../../../../../outside"})+ want := "tenant/logs/runtime/date=2026-07-12/1783873023-claude_code_web-.jsonl.gz"+ if got != want {+ t.Fatalf("ObjectName = %q, want %q", got, want)+ }+}+func TestResolveRunIDUsesOnlyEnvironment(t *testing.T) {t.Setenv("CLAUDE_CODE_REMOTE_SESSION_ID", "cse_env")if got := resolveRunID(); got != "cse_env" {diff --git a/cli/beacon/internal/ci/upload_test.go b/cli/beacon/internal/ci/upload_test.goindex a92dbe80..96876f6b 100644--- a/cli/beacon/internal/ci/upload_test.go+++ b/cli/beacon/internal/ci/upload_test.go@@ -39,7 +39,7 @@ func TestResolveUploadDestinationsRequiresBucket(t *testing.T) {func TestResolveUploadDestinationsRequiresUploadSession(t *testing.T) {t.Setenv(EnvS3Bucket, "beacon-ci")- for _, session := range []string{"", " ", ".."} {+ for _, session := range []string{"", " ", "..", "../../outside"} {if _, err := resolveUploadDestinations([]string{"s3"}, nil, "/tmp/runtime.jsonl", session); err == nil {t.Fatalf("resolveUploadDestinations(session %q) returned no error; an empty session folder would let sessions overwrite each other", session)}@@ -75,6 +75,24 @@ func TestResolveUploadDestinationsBuildsGitHubObjectKeys(t *testing.T) {}}+func TestUploadObjectKeyStaysUnderPrefix(t *testing.T) {+ session := "1700000000-abcd"+ run := &schema.RunInfo{+ Repository: "owner/repo",+ RunID: "../../../../outside",+ RunAttempt: "1",+ Job: "build",+ }+ if got, want := uploadObjectKey("tenant/logs", run, "/tmp/runtime.jsonl", session), "tenant/logs/owner/repo/1/build/"+session+"/runtime.jsonl"; got != want {+ t.Fatalf("key with a parent run id = %q, want %q", got, want)+ }+ run.RunID = "123"+ run.Job = "../../../../../outside"+ if got, want := uploadObjectKey("tenant/logs", run, "/tmp/../../etc/passwd", session), "tenant/logs/owner/repo/123/1/"+session+"/passwd"; got != want {+ t.Fatalf("key with a parent job = %q, want %q", got, want)+ }+}+func TestResolveUploadDestinationsBuildsFallbackObjectKeys(t *testing.T) {t.Setenv(EnvGCSBucket, "beacon-ci")destinations, err := resolveUploadDestinations([]string{"gcs"}, nil, "/tmp/runtime.jsonl", "42-0a0b0c0d")diff --git a/cli/beacon/internal/devincloud/mapper_test.go b/cli/beacon/internal/devincloud/mapper_test.goindex 28167c16..fc908f51 100644--- a/cli/beacon/internal/devincloud/mapper_test.go+++ b/cli/beacon/internal/devincloud/mapper_test.go@@ -156,6 +156,11 @@ func TestObjectNameLayout(t *testing.T) {if got2 != want2 {t.Fatalf("ObjectName empties = %q, want %q", got2, want2)}+ got3 := ObjectName("tenant/logs", "devin_cloud", "user-1", "../../../../../../outside")+ want3 := "tenant/logs/provider=devin_cloud/user_id=user-1/run_id=unknown/runtime.jsonl"+ if got3 != want3 {+ t.Fatalf("ObjectName traversal = %q, want %q", got3, want3)+ }}func TestMapSessionRecordsRetainedMessageContent(t *testing.T) {diff --git a/cli/beacon/internal/devincloud/pull.go b/cli/beacon/internal/devincloud/pull.goindex 679b4b9b..d5c4efcf 100644--- a/cli/beacon/internal/devincloud/pull.go+++ b/cli/beacon/internal/devincloud/pull.go@@ -211,9 +211,9 @@ func marshalEvents(mapped []MappedEvent) ([]byte, error) {// in-sandbox hook providers: {prefix}/provider=.../user_id=.../run_id=.../runtime.jsonlfunc ObjectName(prefix, provider, userID, sessionID string) string {parts := objectkey.CleanParts(prefix)- parts = append(parts, "provider="+defaultIfEmpty(provider, "unknown"))- parts = append(parts, "user_id="+defaultIfEmpty(userID, "unknown"))- parts = append(parts, "run_id="+defaultIfEmpty(sessionID, "unknown"))+ parts = append(parts, "provider="+defaultIfEmpty(objectkey.CleanPart(provider), "unknown"))+ parts = append(parts, "user_id="+defaultIfEmpty(objectkey.CleanPart(userID), "unknown"))+ parts = append(parts, "run_id="+defaultIfEmpty(objectkey.CleanPart(sessionID), "unknown"))parts = append(parts, "runtime.jsonl")return path.Join(parts...)}diff --git a/pkg/asymptoteobserve/objectkey/objectkey.go b/pkg/asymptoteobserve/objectkey/objectkey.goindex a81f2f3e..ef9d0c86 100644--- a/pkg/asymptoteobserve/objectkey/objectkey.go+++ b/pkg/asymptoteobserve/objectkey/objectkey.go@@ -20,13 +20,16 @@ func CleanParts(value string) []string {}// CleanPart makes one value safe to use as a single key segment: it trims spaces, turns-// backslashes into dashes, strips surrounding slashes, and rejects "." and ".." so a value-// cannot climb out of its prefix. It returns "" when nothing usable is left.+// backslashes into dashes, strips surrounding slashes, and rejects ".", "..", and any value+// that still contains a slash. A leftover slash would survive into path.Join, whose Clean+// treats ".." as a parent and can climb out of the configured prefix. It returns "" when+// nothing usable is left. Callers with a slash-separated value, such as a prefix or an+// owner/repo name, use CleanParts.func CleanPart(value string) string {cleaned := strings.TrimSpace(value)cleaned = strings.ReplaceAll(cleaned, "\\", "-")cleaned = strings.Trim(cleaned, "/")- if cleaned == "." || cleaned == ".." {+ if cleaned == "." || cleaned == ".." || strings.Contains(cleaned, "/") {return ""}return cleaneddiff --git a/pkg/asymptoteobserve/objectkey/objectkey_test.go b/pkg/asymptoteobserve/objectkey/objectkey_test.goindex dd9a62ce..9c9695ca 100644--- a/pkg/asymptoteobserve/objectkey/objectkey_test.go+++ b/pkg/asymptoteobserve/objectkey/objectkey_test.go@@ -20,6 +20,24 @@ func TestCleanPartsKeepsValuesInsideTheirPrefix(t *testing.T) {}}+func TestCleanPartIsOneSegment(t *testing.T) {+ for _, value := range []string{".", "..", " .. ", "/", "../foo", "../../etc/passwd", "a/../b", "foo/bar", "/../../etc/passwd/"} {+ if got := CleanPart(value); got != "" {+ t.Errorf("CleanPart(%q) = %q, want empty", value, got)+ }+ }+ for value, want := range map[string]string{+ "runtime": "runtime",+ "foo..bar": "foo..bar",+ `win\path`: "win-path",+ " job-1 ": "job-1",+ } {+ if got := CleanPart(value); got != want {+ t.Errorf("CleanPart(%q) = %q, want %q", value, got, want)+ }+ }+}+func TestEscapeNameKeepsSeparators(t *testing.T) {for name, want := range map[string]string{"runtime/date=2026-10-30/1-claude-run 1.jsonl.gz": "runtime/date=2026-10-30/1-claude-run%201.jsonl.gz",