Closed evilmog closed 3 years ago
Hi @evilmog! Thanks for submitting this issue! Could you possibly give a smaller set of steps required to reproduce this issue ? The python script looks fairly large and complex, wondering if a few cli/api commands chained together could be used to recreate this issue. If not and everything done in the python script is necessary to recreate the bug, could you write down some details as to what is going on in the script and how it is triggering the bug exactly ?
All the script does is configure the test vault to be exactly the same.
Upgrading our binary from 1.7.3 to 1.8.1 breaks user alias templating in the ssh certificate allowed principals.
So to setup:
1: configure vault JWT authentication against your sso provider, make sure it configures groups.
2: configure vault for ssh certificate issuance
3: configure a TLS cert secret
4: create an internal group and policy for the ssh cert
5: create an external group and policy for ssh cert
6: configure an ssh certificate role with specific allowed principals
7: configure TLS issuance for openvpn, plus policy
8: authenticate with the JWT via your oidc sso, give the JWT to vault for a token
Try to request a certificate in the ssh and tls certificate endpoints
Authentication fails with groups assigned and created via the JWT in 1.8.1 while it works in 1.8.3
That script will provision you a vault with JWT auth, you just need to replace some of the redacted elements like bound issuer.
On Tue., Sep. 7, 2021, 5:05 p.m. Pratyoy Mukhopadhyay, < @.***> wrote:
Hi @evilmog https://github.com/evilmog! Thanks for submitting this issue! Could you possibly give a smaller set of steps required to reproduce this issue ? The python script looks fairly large and complex, wondering if a few cli/api commands chained together could be used to recreate this issue. If not and everything done in the python script is necessary to recreate the bug, could you write down some details as to what is going on in the script and how it is triggering the bug exactly ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashicorp/vault/issues/12336#issuecomment-914681764, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZBQUUWLSW5ZSFCD27UQADUA2LCRANCNFSM5CKBZDVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
ah perfect, having that broken down like that is super helpful for me, thank you!! Follow up questions on the script:
You may need to make your own JWT or setup keycloak as an OIDC provider to issue you jwt's with groups
This should work on python 3.8 ish, it's super hacky and I should have down terraform.
You will want to use a token that's not a root token issued from the JWT sign on, you will want a group, we call our groups blueGroups but whatever in the OIDC will populate the JWT SSO groups should work.
That's where I suspect the problem is, either in the templating of the allowed usernames of the key principal or something to do with the JWT but whenever we request the cert with the new token on 1.8.3 we get rejected vs in 1.7.3 we get accepted.
I can line up a WebEx to show you sometime if that would help.
I'll see if I can get an exact method to replicate tomorrow.
On Tue., Sep. 7, 2021, 5:40 p.m. Pratyoy Mukhopadhyay, < @.***> wrote:
ah perfect, having that broken down like that is super helpful for me, thank you!! Follow up questions on the script:
- What is the python version needed to run it?
- Beyond updating the redacted variables and starting up a dev mode vault server on 127.0.0.1:8200, should I need to do anything else to be able to reproduce this ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashicorp/vault/issues/12336#issuecomment-914696948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZBQUSDBFGBJ67CKK5JBATUA2PFLANCNFSM5CKBZDVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
thanks for the additional details! I will try to repro this shortly keeping the advice in mind, let you know here if I run into any issues!
I am wondering if the required options changed in the JWT plugin, I noticed this when I tried to change my number of token uses on the JWT endpoint, it used to default to JWT in the JWT/OIDC options, I wonder if its not set it if breaks.
I'm going to see if I can reload a vault from scratch and see if its fixed that way rather than doing a straight upgrade.
On Thu, Sep 9, 2021 at 2:53 PM Pratyoy Mukhopadhyay < @.***> wrote:
thanks for the additional details! I will try to repro this shortly keeping the advice in mind, let you know here if I run into any issues!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashicorp/vault/issues/12336#issuecomment-916428428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZBQUQRMDMB5Y5FADY55ZLUBENF3ANCNFSM5CKBZDVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Sorry, I haven't gotten around to doing a repro of this yet, but just wanted to check, did the things you were planning to try in your last message end up resolving this or shedding any more light on it ?
I haven't managed to get things going, I'll have to try a full from scratch rebuild so see if I can get this to reproduce
On Wed, Sep 15, 2021 at 5:13 PM Pratyoy Mukhopadhyay < @.***> wrote:
Sorry, I haven't gotten around to doing a repro of this yet, but just wanted to check, did the things you were planning to try in your last message end up resolving this or shedding any more light on it ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashicorp/vault/issues/12336#issuecomment-920453447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZBQUXEJU6UNDCPF4RF7TLUCESCXANCNFSM5CKBZDVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hi guys,
in my opinion its not even required to go via the JWT or OIDC option. We discovered the same bug and it seems an allowed_common_name with the mail address as value is already enough to break it.
docker run --rm -p 8200:8200 --cap-add=IPC_LOCK -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' -d vault:1.7.3
export VAULT_ADDR='http://0.0.0.0:8200'
export VAULT_TOKEN="myroot"
vault secrets enable pki
vault secrets tune -max-lease-ttl=8760h pki
vault write pki/root/generate/internal common_name=test.com ttl=8760h
vault write pki/roles/example allowed_domains=test@test.com allow_bare_domains=true
vault write pki/issue/example common_name=test@test.com
docker run --rm -p 8200:8200 --cap-add=IPC_LOCK -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' vault:1.8.2
export VAULT_ADDR='http://0.0.0.0:8200'
export VAULT_TOKEN="myroot"
vault secrets enable pki
vault secrets tune -max-lease-ttl=8760h pki
vault write pki/root/generate/internal common_name=test.com ttl=8760h
vault write pki/roles/example allowed_domains=test@test.com allow_bare_domains=true
vault write pki/issue/example common_name=test@test.com
Error writing data to pki/issue/example: Error making API request.
URL: PUT http://0.0.0.0:8200/v1/pki/issue/example
Code: 400. Errors:
* common name test@test.com not allowed by this role
Thanks so much for the repro steps @DaspawnW , can confirm that I just tried those, and was able to repro the problem on 1.8x and see that it doesn't exist in 1.7x.
Closing issue as it was fixed within #12716
The fix will be available within the next major release and will be backported to Vault 1.8
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior: Configure vault with JWT and then template under PKI or SSH Certificates the following allowed domain template:
This matches the documentation https://learn.hashicorp.com/tutorials/vault/policy-templating
the vault ssh config is something similar to one configured by this python script:
Expected behavior A certificate issued from
user@domain.com
instead an error is given{'errors': ['common name redacted@redacted.com not allowed by this role']}
the only fix was to downgrade to 1.7.3
Environment:
vault status
): 1.8.1 (fixed in 1.7.3)vault version
): Vault v1.8.1 (4b0264f28defc05454c31277cfa6ff63695a458d)Vault server configuration file(s):
Additional context Add any other context about the problem here.
Worked perfect in 1.7.3, doesn't work in 1.8.1