Security Guide¶
Security Guide¶
The canonical security policy is maintained in the root SECURITY.md.
Operation ID Sanitization¶
Operation IDs are sanitized to:
- Remove dangerous characters
- Keep only alphanumeric characters and underscores
- Ensure they start with a letter (prefixed with op_ if needed)
Parameter Validation¶
Parameters are validated to ensure:
- Required fields (name, in) are present
- Each parameter is a valid dictionary
- Parameter structure follows OpenAPI specification
Tag Validation¶
Tags are validated to: - Ensure they are strings - Remove whitespace - Prevent empty tags
Caching¶
Caching should be handled at the application or platform level.
Security Best Practices¶
For Developers¶
- Always validate input: Use the built-in validation functions
- Sanitize user data: Let the library handle sanitization
- Use HTTPS: Ensure your Azure Functions use HTTPS
- Monitor logs: Check error logs for security issues
- Keep dependencies updated: Regularly update the library
For Deployment¶
- Environment Variables: Use secure environment variables for configuration
- Network Security: Configure proper network security groups
- Access Control: Implement proper authentication and authorization
- Regular Updates: Keep the runtime and dependencies updated
For API Design¶
- Minimal Information: Don't expose sensitive information in OpenAPI specs
- Proper Authentication: Document authentication requirements
- Rate Limiting: Implement rate limiting for your APIs
- Input Validation: Validate all inputs at the application level
- Error Messages: Don't expose internal details in error messages
Security Configuration¶
Custom CSP Policy¶
You can provide a custom CSP policy:
from azure_functions_openapi.swagger_ui import render_swagger_ui
custom_csp = "default-src 'self'; script-src 'self'"
response = render_swagger_ui(custom_csp=custom_csp)
Security Headers¶
Security headers are automatically added to all responses. You can customize them by modifying the render_swagger_ui function.
Logging¶
Security events are logged with appropriate levels:
- INFO: Normal operations
- WARNING: Security warnings (e.g., invalid input)
- ERROR: Security errors (e.g., validation failures)
Security Automation¶
CI/CD Scanning¶
The repository uses automated security scanning:
- Bandit for Python static analysis
- Semgrep for broader rule coverage
Security scans run in GitHub Actions via .github/workflows/security.yml.
For local parity, run make security.
- Dependabot for dependency updates
SBOM Generation¶
Software Bill of Materials (SBOM) generation is supported via CI workflows to track dependency inventory and reduce supply chain risk.
Security Headers Validation¶
Validate that security headers are present on Swagger UI responses:
X-Content-Type-OptionsX-Frame-OptionsReferrer-PolicyContent-Security-Policy
Automated checks should be included in tests or smoke checks for deployments.
Data Privacy and Compliance¶
When processing user data:
- Avoid storing sensitive data in logs
- Minimize data collection and retention
- Use encryption in transit and at rest
- Follow applicable privacy regulations for your region
Incident Response¶
Follow your organization's standard security runbooks for incidents and disclosures.
Reporting Security Issues¶
If you discover a security vulnerability, please:
- Do not create a public issue
- Email security concerns to: yeongseon.choe@gmail.com
- Include detailed information about the vulnerability
- Allow time for the issue to be addressed before disclosure
Security Updates¶
Security updates are released as: - Patch versions (e.g., 1.0.1) for critical security fixes - Minor versions (e.g., 1.1.0) for security improvements - Major versions (e.g., 2.0.0) for breaking security changes
Always update to the latest version to ensure you have the latest security fixes.