Skip to content

reject nul bytes in ssh certificate key ids and principals - #15970

Open
jmestwa-coder wants to merge 1 commit into
pyca:mainfrom
jmestwa-coder:ssh-cert-nul-principals
Open

jmestwa-coder wants to merge 1 commit into
pyca:mainfrom
jmestwa-coder:ssh-cert-nul-principals

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

SSHCertificateBuilder and load_ssh_public_identity accept NUL bytes in a certificate's key ID and principals, but OpenSSH reads both fields as C strings (a trailing NUL is dropped and any other NUL makes the certificate invalid), so a principal of b"root\x00" is signed and reported as-is here while ssh-keygen -L (OpenSSH 10.5p1) and sshd read it as root; both now raise ValueError, with regression vectors for the loader.

# OpenSSH reads the key ID and principals as C strings: it drops a
# trailing NUL and rejects the certificate for any other NUL.
key_id, rest = _get_sshstr(rest)
if b"\x00" in bytes(key_id):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we converting key_id to bytes? 0 in key_id works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants