Skip to content

Security: Pin JWT signing algorithm to prevent algorithm confusion attacks #95

Description

@intel352

Problem

JWT validation checks for *jwt.SigningMethodHMAC type but doesn't verify the specific algorithm (HS256 vs HS384 vs HS512). This could allow algorithm confusion attacks.

Fix

Add explicit algorithm verification:

if token.Method.Alg() != "HS256" {
    return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions