Documentation
¶
Overview ¶
Package flasksession decodes, verifies and forges Flask session cookies (the itsdangerous URLSafeTimedSerializer format). It is a web-pentest primitive directly parallel to the JWT tooling: a Flask session cookie is signed (not encrypted), so its payload is readable by anyone, and an app with a weak or leaked SECRET_KEY can be impersonated by forging an arbitrary session — the classic flask-unsign attack.
Wrap-vs-native judgement ¶
Native. The format is base64url segments (payload[.compressed].timestamp.sig) signed with HMAC-SHA1 under a key derived as HMAC-SHA1(SECRET_KEY, "cookie-session"). It is a few dozen lines over crypto/hmac + crypto/sha1 + compress/zlib; there is nothing to wrap.
Verifiable / no confidently-wrong output ¶
The signing derivation, the timestamp epoch, and the zlib compression were confirmed byte-for-byte against the reference itsdangerous library (the authoritative implementation) — the unit tests gate decode and verify against itsdangerous-produced cookies. The payload is signed-not-encrypted so decode asserts nothing secret; verify is constant-time and reports which candidate SECRET_KEY (if any) validates, never guessing.
Covered / deferred ¶
Covered: decode (payload + timestamp, transparently zlib-inflating compressed payloads), verify against candidate SECRET_KEYs, and forge (sign an arbitrary payload). The TaggedJSONSerializer's type tags ({" b": …} etc.) are surfaced as the raw JSON they are rather than expanded.
Index ¶
Constants ¶
const DefaultSalt = "cookie-session"
DefaultSalt is Flask's SecureCookieSessionInterface salt.
Variables ¶
This section is empty.