AgentsConfigHelper / rules
Cursor rule2 starsChanged 3 months agoMITView on GitHub
Secure file handling & uploads (validation, storage isolation, scanning, safe delivery)
We split this codeguard-0-file-handling-and-uploads.mdc into the rules it gives an agent
15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Ensure input validation is applied before validating extensions.
- Very specific: line 16
Avoid double extensions (e.g., .jpg.php) and null byte injection (e.g., .php%00.jpg).
- Distinctive: line 17
Use allowlist approach rather than denylist for file extensions.
- Distinctive: line 21
Never trust client-supplied Content-Type headers as they can be spoofed.
- Distinctive: line 24
Use file signature validation but not as a standalone security measure.
- Distinctive: line 28
If user filenames required, implement maximum length limits.
- Distinctive: line 31
Avoid leading hyphens or spaces for safer shell script processing.
- Distinctive: line 36
Avoid ZIP files due to numerous attack vectors.
- Distinctive: line 43
If storing in webroot, set write-only permissions with proper access controls.
- Distinctive: line 44
Use application handlers that map IDs to filenames for public access.
- Distinctive: line 45
Consider database storage for specific use cases with DBA expertise.
- Distinctive: line 55
Consider post-decompression size limits for compressed files.
- Distinctive: line 57
Use secure methods to calculate ZIP file sizes safely.
- Distinctive: line 61
Keep all file processing libraries securely configured and updated.
- Distinctive: line 64
Use secure extraction methods for compressed files.
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- description: Secure file handling & uploads (validation, storage isolation, scanning, safe delivery) globs: **/*.c,**/*.go,**/*.h,**/*.java,**/*.js,**/*.jsx,**/*.mjs,**/*.php,**/*.py,**/*.pyi,**/*.pyx,**/*.rb,**/*.ts,**/*.tsx version: 1.0.1 --- rule_id: codeguard-0-file-handling-and-uploads ## File Upload Security Guidelines This rule advises on secure file upload practices to prevent malicious file attacks and protect system integrity: - Extension Validation - List allowed extensions only for business-critical functionality. - Ensure input validation is applied before validating extensions. - Avoid double extensions (e.g., `.jpg.php`) and null byte injection (e.g., `.php%00.jpg`). - Use allowlist approach rather than denylist for file extensions. - Validate extensions after decoding filename to prevent bypass attempts. - Content Type and File Signature Validation - Never trust client-supplied Content-Type headers as they can be spoofed. - Validate file signatures (magic numbers) in conjunction with Content-Type checking. - Implement allowlist approach for MIME types as a quick protection layer. - Use file signature validation but not as a standalone security measure. - Filename Security - Generate random filenames (UUID/GUID) instead of using user-supplied names. - If user filenames required, implement maximum length limits. - Restrict characters to alphanumeric, hyphens, spaces, and periods only. - Prevent leading periods (hidden files) and sequential periods (directory traversal). - Avoid leading hyphens or spaces for safer shell script processing. - File Content Validation - For images, apply image rewriting techniques to destroy malicious content. - For Microsoft documents, use Apache POI for validation. - Avoid ZIP files due to numerous attack vectors. - Implement manual file review in sandboxed environments when resources allow. - Integrate antivirus scanning and Content Disarm & Reconstruct (CDR) for applicable file types. - Storage Security - Store files on different servers for complete segregation when possible. - Store files outside webroot with administrative access only. - If storing in webroot, set write-only permissions with proper access controls. - Use application handlers that map IDs to filenames for public access. - Consider database storage for specific use cases with DBA expertise. - Access Control and Authentication - Require user authentication before allowing file uploads. - Implement proper authorization levels for file access and modification. - Set filesystem permissions on principle of least privilege. - Scan files before execution if execution permission is required. - Upload and Download Limits - Set proper file size limits for upload protection. - Consider post-decompression size limits for compressed files. - Implement request limits for download services to prevent DoS attacks. - Use secure methods to calculate ZIP file sizes safely. - Additional Security Measures - Protect file upload endpoints from CSRF attacks. - Keep all file processing libraries securely configured and updated. - Implement logging and monitoring for upload activities. - Provide user reporting mechanisms for illegal content. - Use secure extraction methods for compressed files. Summary: Implement defense-in-depth for file uploads through multi-layered validation, secure storage practices, proper access controls, and comprehensive monitoring. Never rely on single validation methods and always generate safe filenames to prevent attacks.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/codeguard-0-additional-cryptography.mdcCursor rule
- .cursor/rules/codeguard-0-api-web-services.mdcCursor rule
- .cursor/rules/codeguard-0-authentication-mfa.mdcCursor rule
- .cursor/rules/codeguard-0-authorization-access-control.mdcCursor rule
- .cursor/rules/codeguard-0-client-side-web-security.mdcCursor rule
- .cursor/rules/codeguard-0-cloud-orchestration-kubernetes.mdcCursor rule
- .cursor/rules/codeguard-0-data-storage.mdcCursor rule
- .cursor/rules/codeguard-0-devops-ci-cd-containers.mdcCursor rule
- .cursor/rules/codeguard-0-framework-and-languages.mdcCursor rule
- .cursor/rules/codeguard-0-iac-security.mdcCursor rule
- .cursor/rules/codeguard-0-input-validation-injection.mdcCursor rule
- .cursor/rules/codeguard-0-logging.mdcCursor rule
- .cursor/rules/codeguard-0-mobile-apps.mdcCursor rule
- .cursor/rules/codeguard-0-privacy-data-protection.mdcCursor rule
- .cursor/rules/codeguard-0-safe-c-functions.mdcCursor rule
- .cursor/rules/codeguard-0-session-management-and-cookies.mdcCursor rule
- .cursor/rules/codeguard-0-supply-chain-security.mdcCursor rule
- .cursor/rules/codeguard-0-xml-and-serialization.mdcCursor rule
- .cursor/rules/codeguard-1-crypto-algorithms.mdcCursor rule
- .cursor/rules/codeguard-1-digital-certificates.mdcCursor rule
- .cursor/rules/codeguard-1-hardcoded-credentials.mdcCursor rule
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

