Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 5.31 KB

File metadata and controls

88 lines (63 loc) · 5.31 KB
layout post
date 2026-04-15
lastchange 26-04-15 v002 bottom ver @claude-vulscan.md
url https://bomonike.github.io/claude-vulscan
file claude-vulscan
title Anthropic Claude Vulnerability Scanning Python
excerpt Advances in Mythos and other LLMs are enable to analyze logic of program code. Use the same tool as hackers, before them, to find and fix vulnerabilities.
tags
AI
Security
Vulnerabilities
Anthropic
Claude
image
feature credit creditlink
comments true
created 2026-04-15

claude-vulscan.png {{ page.excerpt }} {% include l18n.html %} {% include _toc.html %}

{% include whatever.html %}

This article was hand-crafted based on AI responses.

The script ran successfully. Claude analyzed myutils.py and found 10 potential security issues:

Issue Location

1 Hardcoded email credential ~line 639 2 Weak file permissions on public key (0o644 → 0o600) ~line 1380 3 URL leakage to third-party (tinyurl) without consent ~line 1261 4 Path traversal in read_file_to_string ~lines 1449-1465 5 TOCTOU race on os.chmod ~lines 1375-1380 6 Private keys stored in predictable ~/.keys location ~line 1327 7 Unprotected private keys (NoEncryption()) ~lines 1337-1339 8 Unvalidated drive_path in subprocess call ~line 1198 9 Encryption key returned in memory (core dump risk) ~line 1485 10 No certificate pinning on requests.get ~line 1257

All good. Here's a summary of the 8 fixes applied to myutils.py:

Issue Fix

1 Hardcoded EMAIL_FROM email Read from os.environ.get("EMAIL_FROM", "") 2 0o644 on public key files (×2) Changed to 0o600 3 TOCTOU (time-of-check to time-of-use) race on file creation + chmod (×4) Replaced open() + chmod with os.open(..., 0o600) 4 No passphrase warning in generate_rsa_keypair Added print_warning when NoEncryption() is used 5 Unvalidated drive_path in eject_drive Validate path resolves under /Volumes/ before passing to subprocess 6 URL leakage in shorten_url Added warning + use requote_uri instead of raw concatenation 7 No path traversal warning in read_file_to_string Warn when base_dir=None — Cert pinning (requests.get) Not fixed — cert pinning requires a specific cert; verify=True is the correct standard practice

  1. Path Traversal - scan_file() and scan_project() accept arbitrary file paths without validation. An attacker could read sensitive files (e.g., --target "/etc/passwd").

  2. Missing Error Handling for API Key - os.environ["ANTHROPIC_API_KEY"] will raise KeyError if unset, causing a crash with a potentially revealing stack trace. Use os.environ.get() with proper handling.

  3. Unvalidated Directory Traversal in scan_project() - os.walk(directory) traverses directories without symlink protection, allowing symlink attacks to access files outside the intended directory.

  4. No File Size Limit - scan_file() reads entire files into memory without size checks, enabling denial-of-service via large files.

  5. Tilde Expansion Not Handled - The default path ~/github-wilsonmar/... won't expand; while noted as a FIXME, using os.path.expanduser() is needed to prevent unexpected behavior.

  6. Path Traversal in read_file_to_string (lines 1890-1907): The base_dir parameter is optional and defaults to None, meaning path traversal protection is only active when explicitly enabled. Most callers don't pass base_dir.

  7. Hardcoded credentials/email (lines 726-727): EMAIL_FROM = "loadtesters@gmail.com" is hardcoded, and email credentials are retrieved based on this fixed value.

  8. Insecure URL shortener (line 1741): shorten_url() uses tinyurl.com API over HTTPS but the shortened URL could redirect anywhere - no validation of the returned URL.

  9. Weak file permission on public key (line 1856): os.chmod(public_key_path, 0o644) makes public keys world-readable, which may be unintended in multi-user environments.

  10. Race condition in force_link (lines 612-623): Despite the comment claiming "eliminates TOCTOU race," there's still a window between os.symlink and os.replace where the temp file exists.

  11. Unsafe deserialization with ast.literal_eval (line 1687): While safer than eval(), processing untrusted Python files could still cause DoS via deeply nested structures.

  12. Unbounded file read in encrypt_symmetrically (lines 1937-1940): Reads entire file into memory without size limits - DoS vector with large files.

  13. Key written to BytesIO but not securely cleared (lines 1950-1953): Encryption key remains in memory in key_out BytesIO object without secure deletion.

  14. No certificate pinning on external requests (line 1741): requests.get() with only verify=True is vulnerable to CA compromise attacks.

  15. Sensitive data in logs (line 1725): get_api_key() logs key length which could leak information about credential format. Remove them or encrypt sensitive values. Rotate keys and store them separately from the logs.

CIS Benchmarks


{{ page.lastchange }} created {{ page.created }}