Skip to content

Commit

Permalink
feat: define new setting ALLOWED_ALGORITHMS
Browse files Browse the repository at this point in the history
It defaults to ["RS256"] and the goal is to mitigate CVE-2024-33663
even though vulnerability does not seem to exist in the context of
tunnistamo or tunnistus (ECDSA is not used by either issuer).
  • Loading branch information
voneiden committed May 20, 2024
1 parent 48369cf commit dc3e452
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.12.0 - 2024-05-20

### Changed

- Add new setting `ALLOWED_ALGORITHMS` with a default value of `["RS256"]`

## 0.11.0 - 2024-03-15

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ OIDC_API_TOKEN_AUTH = {
# authorization server configuration and public keys are "remembered".
# The value is in seconds. Default is 24 hours.
"OIDC_CONFIG_EXPIRATION_TIME": 600,

# Allow only algorithms that we actually use. In case of tunnistamo and
# tunnistus only RS256 is used with API access tokens.
"ALLOWED_ALGORITHMS": ["RS256"],
}
```

Expand Down
7 changes: 6 additions & 1 deletion helusers/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def validate(self, keys, audience, required_claims=_NOT_PROVIDED):
for required_claim in required_claims:
options[f"require_{required_claim}"] = True

jwt.decode(self._encoded_jwt, keys, options=options)
jwt.decode(
self._encoded_jwt,
keys,
algorithms=self.settings.ALLOWED_ALGORITHMS,
options=options,
)

claims = self.claims
if require_aud and "aud" not in claims:
Expand Down
1 change: 1 addition & 0 deletions helusers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
AUTH_SCHEME="Bearer",
USER_RESOLVER="helusers.oidc.resolve_user",
OIDC_CONFIG_EXPIRATION_TIME=24 * 60 * 60,
ALLOWED_ALGORITHMS=["RS256"],
)

_import_strings = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="django-helusers",
version="0.11.0",
version="0.12.0",
packages=["helusers"],
include_package_data=True,
license="BSD License",
Expand Down

0 comments on commit dc3e452

Please sign in to comment.