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

YAML pcrs output of tpm2_eventlog not helpful #3303

Open
robret77 opened this issue Nov 19, 2023 · 2 comments
Open

YAML pcrs output of tpm2_eventlog not helpful #3303

robret77 opened this issue Nov 19, 2023 · 2 comments
Milestone

Comments

@robret77
Copy link

robret77 commented Nov 19, 2023

The computed PCR values at the end of the tpm2_eventlog YAML output can't be parsed correctly by YAML tools like the yq command line or online YAML formatters. The PCR hex values are transformed to float. It would probably be better to encode them as a strings by surrounding the hex values with double quotes. Tested with the current release 5.6 - 2023-11-08.

Sample output of tpm2_eventlog:

$ sudo ./bin/tpm2_eventlog /sys/kernel/security/tpm0/binary_bios_measurements
...
  Event: |-
    Exit Boot Services Returned with Success
pcrs:
  sha256:
...
    1  : 0x2e9a5e07140d956a059b65ef1af6c3c14079ca6f7220a0c0d6bdf1b0412a9a1d
...

Sample output, parsed by yq and other tools:

$ sudo ./bin/tpm2_eventlog /sys/kernel/security/tpm0/binary_bios_measurements | yq
...
      "Event": "Exit Boot Services Returned with Success"
    }
  ],
  "pcrs": {
    "sha256": {
...
      "1": 2.1079134437794185e+76,
...

Expected output of tpm2_eventlog:

...
    1  : "0x2e9a5e07140d956a059b65ef1af6c3c14079ca6f7220a0c0d6bdf1b0412a9a1d"
...
@robret77 robret77 changed the title YAML output of tpm2_eventlog not helpful YAML pcrs output of tpm2_eventlog not helpful Nov 20, 2023
@williamcroberts
Copy link
Member

python's yaml package properly parses this:

{'pcrs': {'sha256': {1: 21079134437794183857440536639578330818725865347780897055713131410320316340765}}}

For untagged nodes spec their is no reason that should be interpreted as float, it should be either string or int.

This is a bug in the parser being used, but I don't disagree everything should be escaped as strings.

@williamcroberts williamcroberts added this to the next milestone Dec 11, 2023
@williamcroberts
Copy link
Member

The more I look into this, this is a jq bug. They actually roll their own parser with bison and flex. It never should choose float. Our work on next will correct all the YAML issues we have in a foolproof way, and provide a --canonical output that will output everything quoted as well as with type information.

@AndreasFuchsTPM AndreasFuchsTPM modified the milestones: 5.7.0, 6.0.0 Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants