@miller-tech/uap 1.148.15 → 1.148.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -221,8 +221,13 @@ _BASH_WRITE_RE = re.compile(
221
221
  re.IGNORECASE,
222
222
  )
223
223
  # A browser LAUNCH (not a lookup: `which firefox` / `command -v chrome` are fine).
224
+ # Match the browser by BASENAME anywhere a command word can start, so an absolute
225
+ # or relative path reaches it too. Anchoring on "name right after the separator"
226
+ # let `nohup /home/u/.cloakbrowser/chromium-146/chrome file:///x.html &` walk
227
+ # straight through the gate — the invocation the model actually reaches for.
224
228
  _BROWSER_RE = re.compile(
225
- r"(?:^|[;&|]|\&\&|\|\|)\s*(?:nohup\s+)?(" + "|".join(BROWSER_BINS) + r")\b",
229
+ r"(?:^|[;&|(]|\|\||&&|\bnohup\b|\bsetsid\b|\bexec\b|\bxargs\b|\benv\b|\bnice\b|\btimeout\b|`|\$\()"
230
+ r"\s*(?:[\w./~+-]*/)?(" + "|".join(BROWSER_BINS) + r")\b",
226
231
  re.IGNORECASE,
227
232
  )
228
233
  _LOOKUP_RE = re.compile(r"^\s*(?:which|command\s+-v|type|whereis)\b", re.IGNORECASE)
@@ -56,6 +56,27 @@ class BashGateTest(unittest.TestCase):
56
56
  code, _ = run("Bash", {"command": "nohup firefox /tmp/a.html &"})
57
57
  self.assertEqual(code, 2)
58
58
 
59
+ def test_browser_by_ABSOLUTE_PATH_is_blocked(self):
60
+ # The bypass the model actually found: the old regex wanted the browser
61
+ # NAME immediately after the separator, so any path to the binary walked
62
+ # straight through the gate.
63
+ for cmd in (
64
+ "nohup /home/u/.cloakbrowser/chromium-146.0.7213.0/chrome file:///tmp/x.html &",
65
+ "/usr/bin/google-chrome-stable /tmp/a.html",
66
+ "setsid ./bin/firefox /tmp/a.html",
67
+ "cd /tmp && /opt/google/chrome/chrome index.html",
68
+ "(chromium /tmp/a.html)",
69
+ ):
70
+ code, out = run("Bash", {"command": cmd})
71
+ self.assertEqual(code, 2, f"{cmd} must be BLOCKED — got {out}")
72
+ self.assertIn("uap verify", out)
73
+
74
+ def test_browser_substring_is_not_blocked(self):
75
+ # `open` is a browser bin on macOS; don't let it swallow openssl/opencode.
76
+ for cmd in ("openssl version", "opencode run --help", "npm run chromedriver:check"):
77
+ code, out = run("Bash", {"command": cmd})
78
+ self.assertEqual(code, 0, f"{cmd} must NOT be blocked — got {out}")
79
+
59
80
  def test_browser_LOOKUP_is_not_blocked(self):
60
81
  # `which firefox` is a capability probe, not a launch — must not false-block.
61
82
  code, _ = run("Bash", {"command": "which firefox chromium 2>/dev/null"})