python-security

Outline safe Python coding practices for common security flaws.

Updated Dec 15, 2025
One-click install
npx skills add https://github.com/scruffydan/AI-Agents --skill python-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-security
Source: https://github.com/scruffydan/AI-Agents/tree/main/source/skills/python-security
Command: npx skills add https://github.com/scruffydan/AI-Agents --skill python-security

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill consolidates Python security best practices, focusing on avoiding unsafe APIs (eval, exec, pickle), enforcing robust input validation, preventing SQL injection, ensuring cryptographic randomness, and promoting safe subprocess and file handling.

Core Features & Use Cases

  • Unsafe API mitigation: Avoid eval/exec/pickle in untrusted code and replace with safe alternatives.
  • Input validation & data sanitization: Apply explicit type checks, bounds validation, and safe parsing.
  • SQL injection prevention: Use parameterized queries and ORM-safe patterns.
  • Crypto-safe operations: Use cryptographically secure randomness and avoid weak RNGs.
  • Subprocess & file handling: Use safe subprocess calls and secure file I/O practices.
  • Use Case: When auditing a Python service that processes user input and stores data, this Skill guides safe coding patterns and review steps.

Quick Start

Review provided Python code to replace unsafe APIs with safe equivalents and enforce input validation, parameterized queries, and secure subprocess usage.

Frequently Asked Questions about python-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent Python security flaws in applications handling user input and databases?

To prevent Python security flaws, enforce strict input validation, use parameterized queries, and avoid unsafe APIs like eval, exec, and pickle. This secures authentication flows, XML parsing, and serialization across scripts and web services.

What is the safest way to handle subprocess execution and file operations in Python?

Safe subprocess execution and file handling require avoiding shell injection by using secure subprocess calls and strict file I/O practices. Guard against unsafe APIs and validate all inputs to protect system commands and file operations from malicious exploitation.

How do I replace unsafe Python APIs like eval, exec, and pickle with safe alternatives?

Replace unsafe Python APIs by eliminating eval, exec, and pickle in untrusted code paths and substituting them with safe alternatives. Enforce robust input validation and explicit type checks to ensure data sanitization and secure parsing.

Does Python cryptographic randomness prevent weak random number generation in authentication flows?

Cryptographic randomness prevents weak RNG issues by using cryptographically secure random number generators. This ensures safe operations in authentication flows and security-sensitive contexts, avoiding the vulnerabilities associated with standard Python random modules.

What are the limitations of relying on basic input validation for Python web services?

Basic input validation alone cannot fully secure Python web services if unsafe APIs like eval or pickle remain in use. Limitations include potential SQL injection if parameterized queries are skipped and subprocess vulnerabilities without safe subprocess calls.