Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT Auth provider: bound_audiences checked while login even if bound_claims are set #25791

Closed
souravs17031999 opened this issue Mar 6, 2024 · 2 comments
Labels
auth/jwt-oidc bug Used to indicate a potential bug docs

Comments

@souravs17031999
Copy link

souravs17031999 commented Mar 6, 2024

Describe the bug
While logging-in to Vault with JWT provider, I am not able to use bound_claims without providing bound_audiences as well but according to docs it says otherwise
For "jwt" roles, at least one of bound_audiences, bound_subject, bound_claims or token_bound_cidrs is required.

To Reproduce
Steps to reproduce the behavior:

  1. Configure JWT backend with keycloak as JWT provider.
POST {{VAULT_ADDR}}/v1/sys/auth/jwt
X-Vault-Token: {{ROOT_TOKEN}}
{
    "type": "jwt"
}
POST {{VAULT_ADDR}}/v1/auth/jwt/config
X-Vault-Token: {{ROOT_TOKEN}}
{
    "jwt_supported_algs": "RS256",
    "jwt_validation_pubkeys": "",
    "jwks_url": "{{KEYCLOAK_URL}}/realms/master/protocol/openid-connect/certs"
}
  1. Configure JWT role with above point in consideration.
curl --location 'http://127.0.0.1:8200/v1/auth/jwt/role/custom-role' \
--header 'Content-Type: application/json' \
--data '{
    "bound_claims": {
        "azp": "service-account-vault"
    },
    "user_claim": "azp",
    "token_policies": ["custom-policy"],
    "role_type": "jwt",
    "token_ttl": "10m",
    "token_no_default_policy": true,
    "token_type": "service"
}'
  1. Now, get access token from Keycloak and login to vault using this JWT token.
curl --location 'http://localhost:8480/auth/realms/VAULT/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=service-account-vault' \
--data-urlencode 'client_secret=<secret>' \
--data-urlencode 'scope=openid'
curl --location 'http://127.0.0.1:8200/v1/auth/certmgmt/login' \
--header 'Content-Type: application/json' \
--data '{
    "jwt": "<jwt>",
    "role": "custom-role"
}'
  1. Now, I get following error:
{
    "errors": [
        "audience claim found in JWT but no audiences bound to the role"
    ]
}

Expected behavior
I should be able to login and get vault service token after validating exp, iss etc.. along with bound_claims and not worry about bound_audiences since I haven't set that explicitly in my role configuration.

Environment:

  • Vault Server Version (retrieve with vault status): 1.11.2
  • Vault CLI Version (retrieve with vault version): Vault v1.11.2 (3a8aa12), built 2022-07-29T09:48:47Z
  • Server Operating System/Architecture: Ubuntu 20.02 (WSL2 distro)

Vault server configuration file(s):

ui            = true
cluster_addr  = "https://127.0.0.1:8201"
api_addr      = "https://127.0.0.1:8200"
disable_mlock = true

storage "postgresql" {
  connection_url = "postgres://user123:secret123!@localhost:5432/postgres?sslmode=disable"
}

listener "tcp" {
  address       = "127.0.0.1:8200"
  tls_disable = 1
}

log_level = "debug"
log_requests_level = "debug"

Additional context

@souravs17031999 souravs17031999 changed the title JWT provider: bound_audiences checked while logging even if bound_claims JWT provider: bound_audiences checked while logging even if bound_claims are set Mar 6, 2024
@souravs17031999 souravs17031999 changed the title JWT provider: bound_audiences checked while logging even if bound_claims are set JWT provider: bound_audiences checked while login even if bound_claims are set Mar 6, 2024
@souravs17031999 souravs17031999 changed the title JWT provider: bound_audiences checked while login even if bound_claims are set JWT Auth provider: bound_audiences checked while login even if bound_claims are set Mar 6, 2024
@peteski22 peteski22 added docs bug Used to indicate a potential bug auth/jwt-oidc labels Mar 6, 2024
@loicgreffier
Copy link

I just got the same issue on v1.16.3: #27343

It was working fine on v1.16.2

@fairclothjm
Copy link
Contributor

Update: We have reverted the behavior change for auth jwt roles. This will be reflected in Vault 1.16.5 and 1.15.11.

However, 1.17 and later will maintain the requirement that the bound_audiences parameter of “jwt” roles is required if the aud claim is set on the JWT. If the aud claim on the JWT is empty, then the bound_audiences is not required on the role.

https://developer.hashicorp.com/vault/api-docs/auth/jwt#bound_audiences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth/jwt-oidc bug Used to indicate a potential bug docs
Projects
None yet
Development

No branches or pull requests

4 participants