Back to skill

Security audit

Chown Tool

Security checks for vulnerabilities and agentic risk

Overview

This is a simple file-ownership utility, but it gives broad local ownership-changing power without safeguards or clear risk disclosure.

Install only if you need a minimal chown helper and will invoke it deliberately on trusted paths. Avoid using it through sudo, privileged automation, or attacker-controlled paths unless it is hardened to reject unsafe targets and return nonzero on failure.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/chown.py:5
Finding

Unvalidated ownership change follows symbolic links

Content
View full analysis

Vulnerability Details

File Location: scripts/chown.py, lines 5-12
Vulnerability Type: Unrestricted filesystem ownership change with symbolic-link following
Risk Level: Medium

Vulnerable Code:

python
parser.add_argument('owner')
parser.add_argument('file')
args = parser.parse_args()
try:
    import pwd, grp
    u, g = args.owner.split(':') if ':' in args.owner else (args.owner, None)
    uid = pwd.getpwnam(u).pw_uid
    gid = grp.getgrnam(g).gr_gid if g else -1
    os.chown(args.file, uid, gid)

Technical Analysis

The tool accepts an arbitrary filesystem path and passes it directly to os.chown. No allowed-root validation, canonical-path verification, file-type check, or symbolic-link restriction is applied.

Python's os.chown follows symbolic links by default. If the tool is executed with elevated privileges and an attacker can supply, create, or replace the target path, a symbolic link can redirect the ownership change to a different file. A path replacement between validation and use would also create a time-of-check/time-of-use risk if path validation were added without using safer descriptor-based operations.

The vulnerability is conditional on the process having sufficient privileges to change ownership and the attacker being able to influence the supplied path or its filesystem components.

Attack Path

  1. A privileged user or service invokes this utility using a path influenced by a less-privileged attacker.
  2. The attacker creates or replaces that path with a symbolic link to a protected file.
  3. The attacker selects an account that should receive ownership, where control over the owner argument is available.
  4. The utility resolves the requested account and invokes os.chown on the attacker-controlled path.
  5. os.chown follows the symbolic link and changes the ownership of the protected target.
  6. Depending on the target's permissions and system policy, t ...[truncated 671 chars]
Remediation
View remediation

Remediation Suggestions

  • Run the utility with the least privileges required and avoid exposing it through unrestricted sudo, setuid wrappers, or privileged services.
  • Restrict targets to explicitly approved directories and reject paths outside those roots.
  • Resolve and verify path components while accounting for symbolic links and filesystem race conditions.
  • If the link itself should be modified, use os.lchown() or os.chown(..., follow_symlinks=False).
  • If symbolic links are not required, explicitly reject them and use descriptor-based operations where supported to reduce path-replacement races.
  • Restrict which destination users and groups may be selected rather than accepting arbitrary account names in privileged contexts.
  • Log the canonical target, requested ownership, invoking identity, and operation result for privileged use.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/chown.py:7
Finding

Ownership-change failures return a successful process status

Content
View full analysis

Vulnerability Details

File Location: scripts/chown.py, lines 7-14
Vulnerability Type: Incorrect error handling and exit status
Risk Level: Low

Vulnerable Code:

python
try:
    import pwd, grp
    u, g = args.owner.split(':') if ':' in args.owner else (args.owner, None)
    uid = pwd.getpwnam(u).pw_uid
    gid = grp.getgrnam(g).gr_gid if g else -1
    os.chown(args.file, uid, gid)
    print(f"Changed: {args.file}")
except Exception as e: print(f"Error: {e}", file=sys.stderr)

Technical Analysis

The broad exception handler prints an error but neither re-raises the exception nor terminates with a nonzero status. After handling the exception, the script reaches the end and normally exits with status 0.

Shell scripts, deployment systems, and privileged automation commonly use process exit status to determine whether a security-sensitive operation succeeded. These callers may therefore continue even though ownership was not changed. Catching every Exception also obscures distinctions between invalid accounts, permission failures, missing paths, and unexpected programming errors.

Attack Path

  1. Automation invokes the utility and relies on its exit status to verify that a required ownership change succeeded.
  2. The ownership operation fails because of an invalid account, inaccessible path, insufficient permissions, path manipulation, or another exception.
  3. The exception handler writes a message to standard error but allows the process to exit successfully.
  4. The caller interprets exit status 0 as confirmation that the expected ownership state is present.
  5. Subsequent operations proceed with incorrect ownership or permission assumptions, potentially exposing data or causing privileged workflow steps to act on an improperly secured file.

Impact Assessment

This issue does not directly grant additional operating-system privileges. Its impact is on the integrity of cal ...[truncated 344 chars]

Remediation
View remediation

Remediation Suggestions

  • Return a nonzero status after reporting an error, for example:

    python
    except (KeyError, PermissionError, FileNotFoundError, ValueError, OSError) as error:
        print(f"Error: {error}", file=sys.stderr)
        sys.exit(1)
    
  • Catch expected exceptions explicitly and allow unexpected programming errors to produce a traceback or be handled by centralized logging.

  • Structure execution through a main() function that returns a documented exit code.

  • Add automated tests confirming that invalid users, invalid groups, missing files, and permission failures all produce nonzero exit statuses.

  • Require callers to verify both the exit status and, where security-critical, the resulting file ownership.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep

Static analysis

No suspicious patterns detected.