Skip to content

Insuficient entropy in CSRF token #23

@randomstuff

Description

@randomstuff

The CSRF token is using 64 bits of entropy :

sha256 = hashlib.sha256()
sha256.update(os.urandom(8))
token = sha256.hexdigest().encode(ENCODING)
response.set_cookie(token_name, token, path=path,
                                  secret=secret, max_age=expires)
request.csrf_token = token.decode(ENCODING)

Apparently, the 128 bits of entropy is considered a minimum these days, the OWASP example is using 512 bits of entropy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions