ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
fix: scrub Bedrock gateway credentials at startup
James Khor8f16794a971e
diff --git a/server/env_scrub.go b/server/env_scrub.goindex b276f81..5a17591 100644--- a/server/env_scrub.go+++ b/server/env_scrub.go@@ -5,7 +5,7 @@ import "os"// secretEnv lists the credentials read from the environment only at startup:// ARTEX_PG_DSN and ARTEX_PG_PASSWORD by NewManager (the password is a separate// variable so Docker Compose does not paste it into a URL), ARTEX_SECRET_KEY,-// and the API keys by agent.FromEnv inside New.+// and the LLM API keys and custom headers by agent.FromEnv inside New.// agent.FromEnv also reads ARTEX_LLM_PROXY and ARTEX_LLM_BASE_URL: both are URLs that// can carry credentials in their userinfo (http://user:pass@proxy:3128). The archive// store also captures ARTEX_ARCHIVE_S3_* credentials during New, before the scrub,@@ -19,6 +19,7 @@ import "os"// the environment: the scrub does not hide them from child processes.var secretEnv = []string{"ARTEX_PG_DSN", "ARTEX_PG_PASSWORD", "ARTEX_SECRET_KEY", "ANTHROPIC_API_KEY", "OPENAI_API_KEY",+ "ARTEX_LLM_API_KEY", "ARTEX_LLM_CUSTOM_HEADERS","ARTEX_LLM_PROXY", "ARTEX_LLM_BASE_URL","ARTEX_ARCHIVE_S3_ACCESS_KEY_ID", "ARTEX_ARCHIVE_S3_SECRET_ACCESS_KEY", "ARTEX_ARCHIVE_S3_SESSION_TOKEN","AWS_ACCESS_KEY_ID", "AWS_ACCESS_KEY", "AWS_SECRET_ACCESS_KEY", "AWS_SECRET_KEY", "AWS_SESSION_TOKEN",diff --git a/server/env_scrub_test.go b/server/env_scrub_test.goindex db88054..335b6bf 100644--- a/server/env_scrub_test.go+++ b/server/env_scrub_test.go@@ -39,6 +39,24 @@ func TestScrubSecretEnvHidesSecretsFromChildren(t *testing.T) {}}+func TestScrubSecretEnvClearsBedrockGatewayCredentials(t *testing.T) {+ // Preserve every startup secret that ScrubSecretEnv may unset for later tests.+ for _, k := range secretEnv {+ t.Setenv(k, os.Getenv(k))+ }+ // Set these independently of secretEnv so the test catches missing entries.+ t.Setenv("ARTEX_LLM_API_KEY", "synthetic-gateway-token")+ t.Setenv("ARTEX_LLM_CUSTOM_HEADERS", "X-Example-Secret: synthetic-header-value")++ ScrubSecretEnv()++ for _, k := range []string{"ARTEX_LLM_API_KEY", "ARTEX_LLM_CUSTOM_HEADERS"} {+ if _, ok := os.LookupEnv(k); ok {+ t.Errorf("%s is still set after ScrubSecretEnv", k)+ }+ }+}+// New must apply the options it receives. An earlier version accepted// ...Option and never called them, so the binary kept the secrets in the// environment while the unit test above still passed.diff --git a/server/envseal_linux_test.go b/server/envseal_linux_test.goindex a11176b..e9fae29 100644--- a/server/envseal_linux_test.go+++ b/server/envseal_linux_test.go@@ -55,6 +55,9 @@ func TestSealedEnvironmentHandoff(t *testing.T) {"ARTEX_SECRET_KEY": "","ANTHROPIC_API_KEY": "sk-ant-test","OPENAI_API_KEY": "=leading-equals",+ // The Bedrock gateway reads a bearer token and supports multiline headers.+ "ARTEX_LLM_API_KEY": "synthetic-gateway-token",+ "ARTEX_LLM_CUSTOM_HEADERS": "X-Example-Secret: synthetic-header-value\nX-Example-Route: demo",// Proxy and endpoint URLs can carry credentials in their userinfo."ARTEX_LLM_PROXY": "http://proxyuser:[email protected]:3128","ARTEX_LLM_BASE_URL": "https://apiuser:[email protected]/v1",