Install
$ agentstack add skill-tao12345666333-amcp-security-best-practices ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ● Filesystem access Used
- ✓ Shell / process execution No
- ● Environment & secrets Used
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Security Best Practices Skill
When writing code, follow these security best practices to prevent common vulnerabilities.
Input Validation
Always validate and sanitize user input:
# ❌ Bad - trusting user input
user_id = request.args.get('id')
query = f"SELECT * FROM users WHERE id = {user_id}"
# ✅ Good - parameterized query
user_id = request.args.get('id')
cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
Validation Checklist
- Validate type, length, format, and range
- Use allowlists over denylists
- Sanitize for the specific output context
- Never trust client-side validation alone
Authentication
Implement secure authentication:
- Use established libraries (e.g., bcrypt, argon2)
- Never store passwords in plain text
- Implement rate limiting on login attempts
- Use secure session management
- Implement proper logout handling
# ✅ Good - using bcrypt
import bcrypt
def hash_password(password: str) -> bytes:
return bcrypt.hashpw(password.encode(), bcrypt.gensalt())
def verify_password(password: str, hash: bytes) -> bool:
return bcrypt.checkpw(password.encode(), hash)
Authorization
Check permissions on every request:
# ✅ Good - checking authorization
def delete_post(post_id: int, user: User):
post = get_post(post_id)
if post.author_id != user.id and not user.is_admin:
raise PermissionError("Not authorized")
delete_post_from_db(post_id)
Secrets Management
Never hardcode secrets:
# ❌ Bad
API_KEY = "sk-1234567890abcdef"
# ✅ Good
import os
API_KEY = os.environ.get('API_KEY')
Environment Variables
- Use
.envfiles for development (in.gitignore) - Use secrets managers in production
- Rotate secrets regularly
- Use different secrets per environment
SQL Injection Prevention
Always use parameterized queries:
# ❌ Bad - string concatenation
cursor.execute(f"SELECT * FROM users WHERE name = '{name}'")
# ✅ Good - parameterized
cursor.execute("SELECT * FROM users WHERE name = ?", (name,))
# ✅ Good - ORM
User.query.filter_by(name=name).first()
XSS Prevention
Escape output and use Content Security Policy:
# ✅ Good - escaping in templates (Jinja2)
{{ user_input }} # Auto-escaped
# ✅ Good - explicit escaping
from markupsafe import escape
safe_output = escape(user_input)
// ❌ Bad
element.innerHTML = userInput;
// ✅ Good
element.textContent = userInput;
CSRF Protection
Implement CSRF tokens:
...
Secure Headers
Set security headers:
# Flask example
@app.after_request
def set_secure_headers(response):
response.headers['X-Content-Type-Options'] = 'nosniff'
response.headers['X-Frame-Options'] = 'DENY'
response.headers['X-XSS-Protection'] = '1; mode=block'
response.headers['Content-Security-Policy'] = "default-src 'self'"
return response
Error Handling
Don't expose sensitive information in errors:
# ❌ Bad - exposing stack trace
except Exception as e:
return {"error": str(e), "stack": traceback.format_exc()}
# ✅ Good - generic error message
except Exception as e:
logger.error(f"Error: {e}", exc_info=True)
return {"error": "An internal error occurred"}
Dependency Security
Keep dependencies updated:
# Check for vulnerabilities
pip-audit
npm audit
snyk test
File Operations
Validate file paths to prevent path traversal:
import os
# ✅ Good - validate path is within allowed directory
def safe_read(user_path: str, base_dir: str) -> str:
full_path = os.path.realpath(os.path.join(base_dir, user_path))
if not full_path.startswith(os.path.realpath(base_dir)):
raise ValueError("Path traversal attempt")
return open(full_path).read()
Logging
Log security events but not sensitive data:
# ❌ Bad - logging passwords
logger.info(f"Login attempt: user={username}, password={password}")
# ✅ Good - logging without sensitive data
logger.info(f"Login attempt: user={username}, success={success}")
Quick Reference
| Vulnerability | Prevention | |--------------|------------| | SQL Injection | Parameterized queries | | XSS | Output encoding, CSP | | CSRF | CSRF tokens | | Path Traversal | Path validation | | Command Injection | Avoid shell=True | | Hardcoded Secrets | Environment variables | | Weak Passwords | bcrypt/argon2, complexity rules |
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: tao12345666333
- Source: tao12345666333/amcp
- License: Apache-2.0
- Homepage: https://x.com/zhangjintao9020/status/1995170132973466018?s=20
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.