Jira (PUP-11457) CSR Custom Attributes / Extensions issue

54 views
Skip to first unread message

Simon Baker (Jira)

unread,
Feb 16, 2022, 9:45:03 AM2/16/22
to puppe...@googlegroups.com
Simon Baker created an issue
 
Puppet / Bug PUP-11457
CSR Custom Attributes / Extensions issue
Issue Type: Bug Bug
Affects Versions: PUP 7.13.1
Assignee: Unassigned
Created: 2022/02/16 6:44 AM
Priority: Normal Normal
Reporter: Simon Baker

I'm trying to use the CSR extensions to pass data across in the request, via the documented extensions process.

I've (programatically) created csr_attributes.yaml files, an example of which is shown below:

custom_attributes:
  1.2.840.113549.1.9.7: RNo6/fdbnbQsPt8zn0uP3IWWGhAMYsjVVs9erOv+veY=
extension_requests:
  pp_preshared_key: RNo6/fdbnbQsPt8zn0uP3IWWGhAMYsjVVs9erOv+veY=
  pp_hostname: a-322vcjyt8x22e.portswigger.internal
  1.3.6.1.4.1.34380.1.2.2: ewogICJhY2NvdW50SWQiIDogIjM2ODMyMTAyMDI5MCIsCiAgImFyY2hpdGVjdHVyZSIgOiAieDg2XzY0IiwKICAiYXZhaWxhYmlsaXR5Wm9uZSIgOiAiZXUtd2VzdC0xYSIsCiAgImJpbGxpbmdQcm9kdWN0cyIgOi
BudWxsLAogICJkZXZwYXlQcm9kdWN0Q29kZXMiIDogbnVsbCwKICAibWFya2V0cGxhY2VQcm9kdWN0Q29kZXMiIDogbnVsbCwKICAiaW1hZ2VJZCIgOiAiYW1pLTAxZTYwNDNlYjBmZmFjMzM2IiwKICAiaW5zdGFuY2VJZCIgOiAiaS0wYzkxMmRhY2F
lNzUwMDRiNiIsCiAgImluc3RhbmNlVHlwZSIgOiAidDMubWVkaXVtIiwKICAia2VybmVsSWQiIDogbnVsbCwKICAicGVuZGluZ1RpbWUiIDogIjIwMjItMDItMTRUMTM6MDM6MjRaIiwKICAicHJpdmF0ZUlwIiA6ICIxOTIuMTY4Ljk1LjEyNCIsCiAg
InJhbWRpc2tJZCIgOiBudWxsLAogICJyZWdpb24iIDogImV1LXd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cost_center: "368321020290"
  pp_region: eu-west-1a
  pp_instance_id: i-0c912dacae75004b6
  pp_image_name: ami-01e6043eb0ffac336
  pp_cloudplatform: AWS
 

When running puppet, it successfully generates the CSR and includes the data in the extensions I expect.  However, this data is not the same as the data it should be - there are extra bytes at the beginning.  For example, the OID 1.2.840.113549.1.9.7 which I'm using for a PSK, in bytes, should be:

[82 78 111 54 47 102 100 98 110 98 81 115 80 116 56 122 110 48 117 80 51 73 87 87 71 104 65 77 89 115 106 86 86 115 57 101 114 79 118 43 118 101 89 61]

However, extracting those from the CSR gives me two extra bytes for free smile.png

[12 44 82 78 111 54 47 102 100 98 110 98 81 115 80 116 56 122 110 48 117 80 51 73 87 87 71 104 65 77 89 115 106 86 86 115 57 101 114 79 118 43 118 101 89 61]

The solution I'm extracting those bytes with is written in Go, so I asked a colleague to try the same in Java - we got the same results sad.png

Please note, that it's all the extension fields that have extra bytes, with the first byte being 12 and the next byte being different.

The client which is generating this CSR is a Fedora box, running "Fedora release 35 (Thirty Five)".  It's running puppet 7.14.0, installed via the RPM "puppet-agent-7.14.0-1.fc34.x86_64"

 

 

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Simon Baker (Jira)

unread,
Feb 16, 2022, 9:50:03 AM2/16/22
to puppe...@googlegroups.com
Simon Baker updated an issue
Change By: Simon Baker
Attachment: fedora-test.portswigger.internal.pem

Simon Baker (Jira)

unread,
Feb 16, 2022, 9:51:03 AM2/16/22
to puppe...@googlegroups.com
Simon Baker updated an issue
I'm trying to use the CSR extensions to pass data across in the request, via the documented extensions process.

I've (programatically) created csr_attributes.yaml files, an example of which is shown below:
{code:java}
{code}

When running puppet, it successfully generates the CSR and includes the data in the extensions I expect.  However, this data is not the same as the data it should be - there are extra bytes at the beginning.  For example, the OID 1.2.840.113549.1.9.7 which I'm using for a PSK, in bytes, should be:

[82 78 111 54 47 102 100 98 110 98 81 115 80 116 56 122 110 48 117 80 51 73 87 87 71 104 65 77 89 115 106 86 86 115 57 101 114 79 118 43 118 101 89 61]

However, extracting those from the CSR gives me two extra bytes for free :)


[12 44 82 78 111 54 47 102 100 98 110 98 81 115 80 116 56 122 110 48 117 80 51 73 87 87 71 104 65 77 89 115 106 86 86 115 57 101 114 79 118 43 118 101 89 61]

The solution I'm extracting those bytes with is written in Go, so I asked a colleague to try the same in Java - we got the same results :(

Please note, that it's *all* the extension fields that have extra bytes, with the first byte being 12 and the next byte being different.


The client which is generating this CSR is a Fedora box, running "Fedora release 35 (Thirty Five)".  It's running puppet 7.14.0, installed via the RPM "puppet-agent-7.14.0-1.fc34.x86_64"

  Output CSR attached.

 

 


 

Josh Cooper (Jira)

unread,
Feb 16, 2022, 2:56:02 PM2/16/22
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-11457
 
Re: CSR Custom Attributes / Extensions issue

SimonB cert extensions are encoded using ASN.1, so every entry is an array of tag, length, value (TLV). The tag 12 corresponds to a UTF8String: https://ruby-doc.org/stdlib-2.7.0/libdoc/openssl/rdoc/OpenSSL/ASN1.html#module-OpenSSL::ASN1-label-Tag+constants So whatever library you're using to parse the extensions should take the tag and length into account and return the appropriate type of object, such as UTF8String vs PrintableString. In Ruby, you'd want to use "OpenSSL::ASN1.decode" and then call the "value" on the returned object.

I'm going to close this as puppet is behaving as expected.

Simon Baker (Jira)

unread,
Feb 17, 2022, 4:55:01 AM2/17/22
to puppe...@googlegroups.com
Simon Baker commented on Bug PUP-11457

Excellent - thanks josh !  All working now smile.png

Reply all
Reply to author
Forward
0 new messages