Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: config get/set print encryption and captcha API keys in clear

Luigi Agosti20bbd62d104b
diff --git a/cmd/pinchtab/cmd_config_actions.go b/cmd/pinchtab/cmd_config_actions.go
index f9cf9eb9..b83468a5 100644
--- a/cmd/pinchtab/cmd_config_actions.go
+++ b/cmd/pinchtab/cmd_config_actions.go
@@ -129,14 +129,28 @@ func displayConfigValue(path, value string) string {
return value
}
-// isSensitiveConfigPath reports whether a config path points at a secret
-// (token/password/credential) so its value is masked before being printed.
+// isSensitiveConfigPath reports whether a config path points at secret material
+// so its value is masked before being printed.
+//
+// The leaf is matched by suffix rather than exact name: the schema's secrets are
+// stateEncryptionKey, capsolverKey and twoCaptchaKey alongside token/password,
+// and an exact-match list silently missed every one of the *Key fields. Suffix
+// matching is confined to the leaf because intermediate segments are
+// user-chosen names (a browser target called "monkey" must not mask the whole
+// subtree). The credentials subtree is secret at every depth, so it matches
+// wherever it appears.
func isSensitiveConfigPath(path string) bool {
segments := strings.Split(strings.ToLower(strings.TrimSpace(path)), ".")
+ for _, segment := range segments {
+ if segment == "credentials" {
+ return true
+ }
+ }
last := segments[len(segments)-1]
- switch last {
- case "token", "password", "secret", "apikey", "apisecret":
- return true
+ for _, suffix := range []string{"token", "password", "secret", "key", "passphrase"} {
+ if strings.HasSuffix(last, suffix) {
+ return true
+ }
}
return false
}
diff --git a/cmd/pinchtab/cmd_config_secret_test.go b/cmd/pinchtab/cmd_config_secret_test.go
new file mode 100644
index 00000000..e0ea1fc0
--- /dev/null
+++ b/cmd/pinchtab/cmd_config_secret_test.go
@@ -0,0 +1,43 @@
+package main
+
+import "testing"
+
+// `pinchtab config get <path>` prints the value, and `config set` echoes it
+// back, so every config path holding secret material must be masked. The
+// schema's secret-bearing fields are capsolverKey, twoCaptchaKey,
+// stateEncryptionKey, password, token and the credentials subtree.
+func TestIsSensitiveConfigPathCoversEverySecretField(t *testing.T) {
+ sensitive := []string{
+ "server.token",
+ "browser.proxy.password",
+ "security.stateEncryptionKey",
+ "autoSolver.external.capsolverKey",
+ "autoSolver.external.twoCaptchaKey",
+ "autoSolver.credentials.login.password",
+ "autoSolver.credentials.signup.email",
+ "browser.targets.default.proxy.password",
+ }
+ for _, path := range sensitive {
+ if !isSensitiveConfigPath(path) {
+ t.Errorf("isSensitiveConfigPath(%q) = false, want true — value would print in clear", path)
+ }
+ }
+}
+
+// Masking must stay narrow enough that ordinary settings remain readable.
+func TestIsSensitiveConfigPathLeavesOrdinarySettingsVisible(t *testing.T) {
+ ordinary := []string{
+ "server.port",
+ "server.bind",
+ "browser.targets.default.provider",
+ "instanceDefaults.mode",
+ "scheduler.maxInflight",
+ "security.allowEvaluate",
+ "observability.activity.retentionDays",
+ }
+ for _, path := range ordinary {
+ if isSensitiveConfigPath(path) {
+ t.Errorf("isSensitiveConfigPath(%q) = true, want false — ordinary setting would be masked", path)
+ }
+ }
+}