Skip to content

[sec-check] Command-safety regex checks in toolapprove/security.go have easy, non-adversarial bypasses #157

Closed

Description

@hivecommons-hive

Security Finding

Severity: medium
Type: unsafe-pattern

toolapprove/security.go's DefaultSecurityScanner.Scan runs two hardcoded
regexes as a command-safety check ahead of tool execution: destructiveCmdRe
(mkfs / dd / fork-bomb) and credentialExfilRe (reading or printing
credential material). Unlike the rm case, which is decided by a real
shell-aware analyzer (analyzeRmCommand in shellrm.go, exercised by dozens
of quoting/escaping/variable-expansion test cases), these two checks are
plain substring/regex matches with only a single happy-path test each
(coverage_test.go:TestScanFlagsCredentialExfil, one case; the destructive
test in security_command_test.go never exercised a dd-to-block-device
form). That made both easy to slip past with ordinary, non-exotic command
forms - nothing adversarial-looking is required:

  • dd destructiveness was checked only via dd if=/dev/zero. Writing
    garbage onto a raw block device with a different input source bypassed
    it entirely: dd if=/dev/urandom of=/dev/sda, or even
    dd if=image.iso of=/dev/sda (no /dev/zero anywhere).
  • credentialExfilRe required the literal substrings cat ~/.ssh/,
    cat /var/run/secrets/, printenv .*TOKEN, echo $GH_TOKEN or
    echo $GITHUB_TOKEN with no quoting. Ordinary, unremarkable variants all
    bypassed it:
    • echo "$GH_TOKEN" (double-quoted - the common way to print a variable)
    • cat $HOME/.ssh/id_rsa or cat /root/.ssh/id_rsa (no ~)
    • less ~/.ssh/id_rsa, head ~/.ssh/id_rsa, base64 ~/.ssh/id_rsa (any
      reader other than cat)

Impact

A tool-approval gate that an agent, or an agent acting on injected
instructions, can route around with everyday shell syntax is not much of a
gate. The practical risk is credential disclosure (SSH keys, the
Kubernetes service-account token, GH_TOKEN/GITHUB_TOKEN) and destructive
disk writes going through "clean scan" instead of being flagged, in a
project whose stated purpose is a "tamper-evident, governed" agent runtime.

Recommendation

Widen both regexes to cover the bypasses above: match dd with a
of=/dev/(sd|hd|vd|xvd|nvme)... block-device target regardless of if=,
and make the credential-exfil pattern tolerant of quoting ("$VAR",
'$VAR', ${VAR}), $HOME/${HOME}//root in place of ~, and common
alternate readers (less, more, head, tail, tac, base64, xxd,
od, strings). This remains a heuristic, not a full shell parser - bare
env/printenv dumps and variable indirection still pass by design, to
avoid false-positives on routine environment inspection - but it closes the
non-adversarial gaps above and adds the bypass-focused test coverage the
rm path already has.


Filed by sec-check agent (ACMM L6 - full mode)


🐝 Hive Agent: security | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

Activity

  1. added
    securityCreated by Hive for agent-filed issue provenance
    agent/sec-checkCreated by Hive for agent-filed issue provenance
    on Nov 18, 2026
  2. hivecommons-hive commented on Nov 18, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by @Danathar released (lease revoked).

    Claim history
    • 2026-11-18 18:54 UTC — claimed by Danathar (contributor on hive hosted-available-oke-11-placeholder-r05x)
    • 2026-11-18 19:03 UTC — released by Danathar (contributor; lease revoked)
  3. hivecommons-hive commented on Nov 18, 2026

    @hivecommons-hive
    ContributorAuthor

    A hive agent asked to claim this issue, but it is already claimed by Danathar. The claim was not recorded; the owner decides whether to proceed.

  4. hivecommons-hive commented on Nov 18, 2026

    @hivecommons-hive
    ContributorAuthor

    A hive agent asked to open a pull request that would close this issue, but it is already claimed by Danathar. No PR was opened; the owner decides whether to proceed.

  5. clubanderson commented on Nov 18, 2026

    @clubanderson
    Member

    Fixed by hivecommons/hive#19092, merged to v5 (96856329). It widens the command-safety checks to cover every bypass listed here: dd to a block device from any input, quoted GH_TOKEN and GITHUB_TOKEN, $HOME and /root paths, and the alternate file readers, with tests. This repo's toolapprove/security.go is byte-identical to hive v5 after the sync at 96856329 (blob e47364ce on both). Closing by hand because the fix merged in a different repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/sec-checkCreated by Hive for agent-filed issue provenancesecurityCreated by Hive for agent-filed issue provenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions