From 3f3a3f601a499a999f73974bacb76756d202656e Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 12:17:25 +0200 Subject: [PATCH 1/2] fix(verify): write .verify.out owner-only `.verify.out` holds the command's raw combined output, so a command that prints a credential leaves the value in it, and the store writer's 0644 left that readable by every local user. Write it at 0600, the permission `run` already gives `.run.out`; the recorded tail in `patch.json` and the deep-validation receipts stay redacted and 0644 as before. Add `.WriteFileMode(` to wrapcheck's ignore-sigs beside `.WriteFile(`: both seal their errors at the store boundary (GO-ERRORS-03). --- .changeset/verify-out-owner-only.md | 10 ++++++++++ .golangci.yml | 1 + docs/manual.md | 3 ++- internal/core/verify/service.go | 7 ++++++- internal/core/verify/service_test.go | 23 +++++++++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .changeset/verify-out-owner-only.md diff --git a/.changeset/verify-out-owner-only.md b/.changeset/verify-out-owner-only.md new file mode 100644 index 000000000..fb9bf03aa --- /dev/null +++ b/.changeset/verify-out-owner-only.md @@ -0,0 +1,10 @@ +--- +"@stainless-code/verdict": patch +--- + +`verify` writes `.verify.out` at `0600` on Unix instead of `0644`: the stream is +the command's raw output, so a command that prints a credential leaves the value +in it, and the file is now the operator's to read and nobody else's — the same +permission `run` gives `.run.out`. The recorded tail in `patch.json` and the +deep-validation receipts stay redacted as before. Windows has no mode bits to +set, so there the file keeps the directory's inherited ACL. diff --git a/.golangci.yml b/.golangci.yml index 11689ad22..364e7fe63 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -266,6 +266,7 @@ linters: - .NewErr( - .NewErrf( - .WriteFile( + - .WriteFileMode( formatters: enable: diff --git a/docs/manual.md b/docs/manual.md index 288339082..552358c4b 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -3333,7 +3333,8 @@ environment, and the split is deliberate (the security rationale is in your secret-named variables and the argument secrets the argv redaction hides, so the argv and the tail agree about what a credential is. `.run.out` is the child's raw stream — it may hold a credential the child printed — so - it is written `0600` on Unix, the way `.verify.out` keeps its raw stream. + it is written `0600` on Unix, the permission `verify` gives `.verify.out`, + its raw stream beside `patch.json`. Windows has no mode bits for Go to set, so there it takes the directory's inherited ACL and the owner-only guarantee does not apply. diff --git a/internal/core/verify/service.go b/internal/core/verify/service.go index 541c9c245..a92bedb38 100644 --- a/internal/core/verify/service.go +++ b/internal/core/verify/service.go @@ -296,8 +296,13 @@ func recordOutcome(dir, now string, exit int, timedOut bool, tail string, sandbo return nil } +// verifyOutputMode is .verify.out's permission: the stream is raw, so a command +// that prints a credential leaves the value in it, and the file is the +// operator's to read and nobody else's, unlike the 0644 store files beside it. +const verifyOutputMode = 0o600 + func writeOutputs(outPath, combined string) error { - return atomic.WriteFile(outPath, []byte(combined)) + return atomic.WriteFileMode(outPath, []byte(combined), verifyOutputMode) } func recordTimeoutMarker(timeoutPath, marker string) *core.RefusalError { diff --git a/internal/core/verify/service_test.go b/internal/core/verify/service_test.go index 1ea527206..4544a0018 100644 --- a/internal/core/verify/service_test.go +++ b/internal/core/verify/service_test.go @@ -5,6 +5,7 @@ import ( "context" "os" "path/filepath" + "runtime" "strings" "testing" "time" @@ -192,6 +193,28 @@ func TestVerifyRedaction(t *testing.T) { } } +// TestVerifyOutputOwnerOnly pins .verify.out's permission: the stream is raw, +// so a command that prints a credential leaves the value in it, and the file is +// the operator's to read and nobody else's, the way .run.out is. +func TestVerifyOutputOwnerOnly(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("NTFS carries no POSIX mode bits") + } + bundle(t, `{"verifyCmd":"printf tok"}`) + cmdr := &scriptCommander{res: core.Result{Stdout: "tok=leakedvalue123"}} + if _, ref := verifycore.Run(context.Background(), + verifyRequest(&collector{}, cmdr, "10", []string{"PATH=/bin"}, true)); ref != nil { + t.Fatalf("Run refusal: %v", ref) + } + info, err := os.Stat(".verdict/state/5201/.verify.out") + if err != nil { + t.Fatalf("stat .verify.out: %v", err) + } + if perm := info.Mode().Perm(); perm != 0o600 { + t.Errorf(".verify.out mode = %#o, want 0o600", perm) + } +} + // TestVerifyTimeout proves a timed-out run records timedOut with the // seconds marker. func TestVerifyTimeout(t *testing.T) { From 96783291227997eb3f82710b9fc2d92620e3ef86 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Mon, 16 Nov 2026 12:21:07 +0200 Subject: [PATCH 2/2] style(verify): trim the owner-only comments --- internal/core/verify/service.go | 4 +--- internal/core/verify/service_test.go | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/core/verify/service.go b/internal/core/verify/service.go index a92bedb38..5bd858799 100644 --- a/internal/core/verify/service.go +++ b/internal/core/verify/service.go @@ -296,9 +296,7 @@ func recordOutcome(dir, now string, exit int, timedOut bool, tail string, sandbo return nil } -// verifyOutputMode is .verify.out's permission: the stream is raw, so a command -// that prints a credential leaves the value in it, and the file is the -// operator's to read and nobody else's, unlike the 0644 store files beside it. +// raw output can carry a printed credential, so it is owner-only like .run.out. const verifyOutputMode = 0o600 func writeOutputs(outPath, combined string) error { diff --git a/internal/core/verify/service_test.go b/internal/core/verify/service_test.go index 4544a0018..cf9631822 100644 --- a/internal/core/verify/service_test.go +++ b/internal/core/verify/service_test.go @@ -193,9 +193,6 @@ func TestVerifyRedaction(t *testing.T) { } } -// TestVerifyOutputOwnerOnly pins .verify.out's permission: the stream is raw, -// so a command that prints a credential leaves the value in it, and the file is -// the operator's to read and nobody else's, the way .run.out is. func TestVerifyOutputOwnerOnly(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("NTFS carries no POSIX mode bits")