Hidden directories become part of the execution boundary, which means untrusted files can run with the same privileges as trusted project tests. That creates a path for credential theft, data exfiltration, or malicious side effects during routine development and CI runs. The failure is not in the agent itself, but in the toolchain’s assumption about where executable code may live.
Why This Matters for Security Teams
Hidden directories in test discovery change the boundary of what the build system treats as trusted code. That matters because test runners often execute with broad developer or CI privileges, so a file placed outside the intended test tree can still inherit access to secrets, network endpoints, and write permissions. The practical failure is a trust-boundary mistake, not a compiler bug.
For security teams, this is the same class of issue that shows up when organisations fail to map where executable artifacts can appear and who can influence them. NHIMG research on the Top 10 NHI Issues shows how often excessive privilege and weak visibility turn routine automation into an attack path. That pattern also aligns with the NIST Cybersecurity Framework 2.0 emphasis on protecting execution environments, not just authenticating users.
Security practitioners usually miss this when they assume discovery logic is a harmless convenience feature. In practice, many teams discover the problem only after a dependency install, repo sync, or CI test run has already executed code from a location nobody meant to trust.
How It Works in Practice
Most test frameworks build their execution set from filesystem patterns, naming conventions, or recursive discovery rules. When hidden directories are included, the toolchain stops distinguishing between “project-owned test code” and “anything under the repository that matches the pattern.” That means an attacker, a careless contributor, or even a compromised automation step can place executable files in a dot-directory and still get them run.
The operational risk is highest when discovery happens before policy checks. A file can be picked up during local development, pre-commit hooks, or CI pipelines before anyone notices it sits in a hidden path. If those tests can reach environment variables, cloud metadata, package registries, or internal APIs, they can exfiltrate secrets or trigger side effects. NHIMG’s Ultimate Guide to NHIs is explicit that secrets sprawl and excessive privilege are common failure modes in automated environments.
- Scope discovery to explicit test roots instead of recursive “all files” matching.
- Exclude hidden directories unless there is a documented and reviewed need to include them.
- Run tests with the minimum runtime permissions needed for the job.
- Keep secrets out of the process environment where test code can read them directly.
- Review CI job permissions and workspace mounts the same way you review application access.
Good governance also means lifecycle control for automation assets, not just human accounts. The NHI Lifecycle Management Guide is useful here because discovery rules, runner credentials, and test fixtures all need ownership, review, and revocation paths. These controls tend to break down in monorepos with nested package tooling, where multiple runners apply different discovery rules and hidden paths get pulled in through indirect configuration.
Common Variations and Edge Cases
Tighter discovery rules often increase maintenance overhead, requiring teams to balance safer execution boundaries against developer convenience and legacy layout constraints. That tradeoff becomes more visible in monorepos, generated test trees, and repositories that intentionally store fixtures or integration harnesses in dot-directories.
There is no universal standard for this yet, but current guidance suggests treating hidden directories as excluded by default unless a team has a documented reason to include them and compensating controls are in place. The key question is not whether the path is hidden, but whether the path can influence execution. A hidden directory used only for harmless metadata is lower risk than one containing scripts, plugins, or test helpers.
Edge cases also arise when test discovery is delegated to plugins, language runtimes, or CI templates. In those environments, a local exclusion rule may be bypassed by another layer of automation, so teams should verify the effective discovery set end to end. For broader governance on secrets and automation exposure, NHIMG’s Top 10 NHI Issues remains a useful reference for spotting where privilege and visibility gaps turn into execution risk.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10, CSA MAESTRO and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Hidden test discovery can expose privileged automation identities to untrusted code. |
| NIST CSF 2.0 | PR.AC-4 | This is a least-privilege execution boundary problem in build and test systems. |
| NIST AI RMF | GOVERN | Automated test discovery needs accountable ownership and policy oversight. |
| CSA MAESTRO | TRUST-03 | Agentic-style automation should not execute code from unvetted filesystem locations. |
| OWASP Agentic AI Top 10 | A2 | Untrusted code execution via discovery is an agentic toolchain abuse pattern. |
Limit where NHI-backed automation can execute and review every path that can access secrets.