Skip to content

The agent that grows with you

fix(plugin-guard): Google installed-app OAuth client secrets no longer hard-block a plugin install

teknium118fa38463490
diff --git a/tests/tools/test_plugin_guard.py b/tests/tools/test_plugin_guard.py
index 7b08b9c8a49..91e6b38d545 100644
--- a/tests/tools/test_plugin_guard.py
+++ b/tests/tools/test_plugin_guard.py
@@ -866,3 +866,19 @@ class TestIntakeFalsePositiveRound3:
result = scan_plugin(_mk_plugin(tmp_path, files), source="owner/repo")
sevs = {f.severity for f in result.findings if f.pattern_id == pattern_id}
assert sevs == {severity}, format_scan_report(result)
+
+ def test_google_installed_app_client_secret_is_caution_not_dangerous(self, tmp_path):
+ """A ``GOCSPX-`` literal is a Google installed-app OAuth client secret, which ships in every
+ copy of the app: reviewable caution. Any other secret-shaped literal still hard-blocks."""
+ files = dict(BASE_FILES)
+ files["oauth.py"] = 'CLIENT_SECRET = "GOCSPX-abcdefghijklmnopqrstuvwxyz12"\n'
+ (tmp_path / "google").mkdir()
+ (tmp_path / "other").mkdir()
+ result = scan_plugin(_mk_plugin(tmp_path / "google", files), source="owner/repo")
+ assert {f.severity for f in result.findings if f.pattern_id == "hardcoded_secret"} == {"high"}
+ assert result.verdict == "caution"
+
+ files["oauth.py"] = 'CLIENT_SECRET = "Xabcdefghijklmnopqrstuvwxyz1234"\n'
+ result = scan_plugin(_mk_plugin(tmp_path / "other", files), source="owner/repo")
+ assert {f.severity for f in result.findings if f.pattern_id == "hardcoded_secret"} == {"critical"}
+ assert result.verdict == "dangerous"
diff --git a/tools/plugin_guard.py b/tools/plugin_guard.py
index e33ac9c73e6..d24e7853035 100644
--- a/tools/plugin_guard.py
+++ b/tools/plugin_guard.py
@@ -17,7 +17,8 @@ from typing import Iterator, List, Optional, Tuple
from tools.plugin_guard_context import (
STEP_DOWN, catalog_cap, is_agent_facing, is_base64_media, is_ci_workflow, is_coin_name_only, is_data_decode,
- is_doc_prose, is_hex_in_char_class, is_inert_fixture_line, is_json_prose_value, is_locale_catalog,
+ is_doc_prose, is_google_installed_app_secret, is_hex_in_char_class, is_inert_fixture_line,
+ is_json_prose_value, is_locale_catalog,
is_loopback_continuation, is_loopback_only, is_pip_install_in_prose_literal, is_regex_alternation_token,
is_self_uninstall_doc, is_test_tree, logical_line, prose_cap)
from tools.skills_guard import (
@@ -248,6 +249,8 @@ def _context_severity(f: Finding, rel_path: str, line: str, joined: str, doc_pro
sev = "low" # `[\x00-\x1F\x7F]`: a control-char filter, not an assembled payload
if is_coin_name_only(f, line):
sev = _at_most(sev, "medium") # "monero gateway" in a connector index, no miner on the line
+ if is_google_installed_app_secret(f, line):
+ sev = _at_most(sev, "high") # public installed-app OAuth client secret, reviewable caution
if is_code and is_pip_install_in_prose_literal(f, line):
sev = "low" # "no pip install is needed" in a user-facing message
return sev
diff --git a/tools/plugin_guard_context.py b/tools/plugin_guard_context.py
index 36e3fb7ee60..211b9c60242 100644
--- a/tools/plugin_guard_context.py
+++ b/tools/plugin_guard_context.py
@@ -450,10 +450,23 @@ def is_coin_name_only(finding: Finding, line: str) -> bool:
return bool(hits) and all(_is_standalone_coin_name(line, h.start(), h.end()) for h in hits)
+# Google mints installed-app (desktop/CLI) OAuth clients with a ``GOCSPX-`` secret that its OAuth
+# docs say cannot be kept confidential: every copy of the app ships it (gcloud does). A plugin is
+# such an app, so the literal identifies a public client rather than leaking a credential; it stays
+# in the report for review (caution) instead of hard-blocking the install.
+_GOOGLE_PUBLIC_CLIENT_SECRET = re.compile(r'["\']GOCSPX-[A-Za-z0-9_-]{20,}["\']')
+
+
+def is_google_installed_app_secret(finding: Finding, line: str) -> bool:
+ """A ``hardcoded_secret`` hit whose literal is a Google installed-app OAuth client secret."""
+ return finding.pattern_id == "hardcoded_secret" and bool(_GOOGLE_PUBLIC_CLIENT_SECRET.search(line))
+
+
__all__ = [
"STEP_DOWN", "DOC_PROSE_EXTENSIONS", "TEST_TREE_DIRS", "LITERAL_INERT_PATTERN_IDS",
"is_doc_prose", "is_ci_workflow", "is_agent_facing", "prose_cap", "is_self_uninstall_doc", "is_test_tree",
"is_inert_fixture_line", "is_base64_media",
"is_regex_alternation_token", "is_data_decode", "is_loopback_only", "is_pip_install_in_prose_literal",
"is_hex_in_char_class", "logical_line", "is_loopback_continuation", "is_json_prose_value", "is_coin_name_only",
+ "is_google_installed_app_secret",
]