ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
fix(traffic): keep spilled capture blobs owner-only
Coff0xc19110a4727ad
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5af6fb6..8ae6b52 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. The format is b### Fixed+- **Captured traffic blobs are owner-only**: HTTP and raw-stream bodies spilled out of the database are written `0600`, and their bucket directory is `0700`. An existing blob is tightened when it is seen again.- **Docker Compose database passwords with URL-special characters**: `docker-compose.yml` no longer pastes `POSTGRES_PASSWORD` into `ARTEX_PG_DSN`. The server builds the URL from `ARTEX_PG_HOST`, `ARTEX_PG_PORT`, `ARTEX_PG_USER`, `ARTEX_PG_PASSWORD`, `ARTEX_PG_DBNAME` and `ARTEX_PG_SSLMODE`, percent-encoding the user and password, so `/`, `?`, `%`, `@`, `:` and spaces connect. An explicit `ARTEX_PG_DSN` still wins and is not rewritten. `ARTEX_PG_PASSWORD` is removed from the environment with the other startup secrets (#450).## [0.7.0] - 2026-11-21diff --git a/traffic/blob_perm_test.go b/traffic/blob_perm_test.gonew file mode 100644index 0000000..4fc5a78--- /dev/null+++ b/traffic/blob_perm_test.go@@ -0,0 +1,38 @@+package traffic++import (+ "bytes"+ "os"+ "path/filepath"+ "runtime"+ "testing"+)++func TestSpillBlobIsOwnerOnly(t *testing.T) {+ dir := t.TempDir()+ tr := &Traffic{dir: dir}+ body := bytes.Repeat([]byte("a"), maxInlineBody+1)+ got := tr.spill(body, "text/plain")+ if got.hash == "" {+ t.Fatal("expected a spilled blob")+ }+ blobDir := filepath.Join(dir, "_blobs", "sha256", got.hash[:2])+ blobPath := filepath.Join(blobDir, got.hash+".bin")+ info, err := os.Stat(blobPath)+ if err != nil {+ t.Fatal(err)+ }+ dirInfo, err := os.Stat(blobDir)+ if err != nil {+ t.Fatal(err)+ }+ if runtime.GOOS == "windows" {+ return+ }+ if info.Mode().Perm() != 0o600 {+ t.Fatalf("blob mode %o, want 0600", info.Mode().Perm())+ }+ if dirInfo.Mode().Perm() != 0o700 {+ t.Fatalf("blob dir mode %o, want 0700", dirInfo.Mode().Perm())+ }+}diff --git a/traffic/raw_tcp.go b/traffic/raw_tcp.goindex 5bb7a74..ace0167 100644--- a/traffic/raw_tcp.go+++ b/traffic/raw_tcp.go@@ -63,7 +63,7 @@ func (t *Traffic) spillRawDir(data []byte, previewCap int) (preview []byte, blobsum := sha256.Sum256(data)h := hex.EncodeToString(sum[:])blobDir := filepath.Join(t.dir, "_blobs", "sha256", h[:2])- if err := os.MkdirAll(blobDir, 0o755); err != nil {+ if err := os.MkdirAll(blobDir, 0o700); err != nil {log.Printf("[traffic/socks5] failed to create blob directory: %v", err)return append([]byte(nil), data[:previewCap]...), ""}@@ -96,7 +96,7 @@ func writeBlobAtomic(blobDir, blobPath, hash string, data []byte) error {_ = tmp.Close()return err}- if err := tmp.Chmod(0o644); err != nil {+ if err := tmp.Chmod(0o600); err != nil {_ = tmp.Close()return err}diff --git a/traffic/traffic.go b/traffic/traffic.goindex 8eba165..8b3ae51 100644--- a/traffic/traffic.go+++ b/traffic/traffic.go@@ -873,16 +873,21 @@ func (t *Traffic) spillAt(body []byte, contentType string, maxInline int) stored// One bucket level (256 buckets) is enough to keep any single directory small;// the store only ever holds bodies above maxInlineBody, deduplicated by hash.blobDir := filepath.Join(t.dir, "_blobs", "sha256", h[:2])- if err := os.MkdirAll(blobDir, 0o755); err != nil {+ if err := os.MkdirAll(blobDir, 0o700); err != nil {log.Printf("[traffic] failed to create blob directory: %v", err)return storedBody{inline: clipBytes(body, blobPreview), index: indexText()}}+ if err := os.Chmod(blobDir, 0o700); err != nil {+ log.Printf("[traffic] failed to restrict blob directory: %v", err)+ }blobPath := filepath.Join(blobDir, h+".bin")if _, err := os.Stat(blobPath); os.IsNotExist(err) {- if err := os.WriteFile(blobPath, body, 0o644); err != nil {+ if err := os.WriteFile(blobPath, body, 0o600); err != nil {log.Printf("[traffic] failed to write blob %s: %v", h, err)return storedBody{inline: clipBytes(body, blobPreview), index: indexText()}}+ } else if err := os.Chmod(blobPath, 0o600); err != nil {+ log.Printf("[traffic] failed to restrict blob %s: %v", h, err)}sb := storedBody{hash: h, index: indexText()}if text {