flask-talisman
HTTP security headers for Flask.
What it is and what it does
Flask-Talisman is a lightweight Flask extension that wraps your application to automatically inject security-focused HTTP headers. It enforces HTTPS by default (unless debug mode is on), enables HTTP Strict Transport Security, sets secure session cookies, and applies a strict Content Security Policy to mitigate XSS attacks. It also prevents clickjacking via X-Frame-Options, disables MIME type sniffing, and controls referrer leakage.
The extension is designed to be drop-in: you instantiate it with your Flask app and it handles header injection on every response. Most settings are configurable—you can adjust CSP rules, HSTS behavior, frame options, and cookie attributes to match your application's needs. The package has no runtime dependencies, making it lightweight to add to an existing Flask project.
Use it for:
- Add HTTPS enforcement and HSTS headers to a Flask app without manual header management.
- Protect against XSS attacks by applying a strict default Content Security Policy.
- Prevent clickjacking by setting X-Frame-Options and other framing controls.
- Secure session cookies automatically by marking them as secure, httponly, and samesite.
- Customize security headers per-view to allow exceptions for specific endpoints.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask extension that automatically sets HTTP security headers to protect against common web vulnerabilities like XSS, clickjacking, and MIME sniffing.
Yes, with conditions. Flask-Talisman is a straightforward, low-friction way to add essential security headers to Flask applications. It has no dependencies, installs cleanly, and is marked Production/Stable. However, the package is dormant—last updated in August 2023—so verify that its defaults and behavior align with current security best practices and your Flask version before deploying to production.
Install
flask-talisman on PyPI
pip
pip install flask-talismanuv
uv add flask-talismanpoetry
poetry add flask-talismanInstalling flask-talisman
Before you install
Low friction installation with no runtime dependencies. Maintenance is dormant—last release was in August 2023, though the repository remains active and the package is marked Production/Stable.
License in practice
Licensed under Apache Software License (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
pip install flask-talisman
from flask import Flask
from flask_talisman import Talisman
app = Flask(__name__)
Talisman(app)
Verify before relying
- Whether dormant status affects compatibility with recent Flask versions or modern security standards.
- Current test coverage and whether the package has been validated against recent security guidelines.
- Compatibility with Python versions beyond 3.9, given the classifier list ends there.
Package facts
| License | Apache Software License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,107 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,478,870/month — #3,046 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_talisman-1.1.0-py2.py3-none-any.whl
Keywords: flask, security, https, xss
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
secureApplies HTTP security headers to Python web…
permissive · top 5,000 on PyPI
Flask-ParanoidFlask-Paranoid detects and blocks session…
permissive · top 15,000 on PyPI
SecwebSecweb applies security headers (CSP, HSTS,…
copyleft · top 15,000 on PyPI
asgi-csrfASGI middleware that protects web applications…
permissive · top 15,000 on PyPI
hstspreloadProvides a single function to check whether a…
permissive · top 15,000 on PyPI
flask-unsignCommand-line tool to decode, brute-force, and…
permissive · top 15,000 on PyPI
flask-corsFlask-CORS handles Cross-Origin Resource…
permissive · top 1,000 on PyPI
fastapi-csrf-protectAdds stateless CSRF protection to FastAPI…
permissive · top 15,000 on PyPI
django-permissions-policySets the Permissions-Policy HTTP header on…
permissive · top 15,000 on PyPI
django-cspDjango-CSP adds Content-Security-Policy headers…
permissive · top 5,000 on PyPI