Skip to content

Add regex and tests for PEM formatted private key#179

Merged
bee-san merged 1 commit intobee-san:mainfrom
alfredtso:PemPrivateKeyRegex
Oct 8, 2021
Merged

Add regex and tests for PEM formatted private key#179
bee-san merged 1 commit intobee-san:mainfrom
alfredtso:PemPrivateKeyRegex

Conversation

@alfredtso
Copy link
Copy Markdown
Contributor

The regex will match private key generated by ssh-keygen and those
defined by OpenSSL header file. The regex, however, doesn't validate if
the string within BEGIN and END label is "correct" Base64 encoded. As it
can be validated be direct checking with the public key

Resolves: #174

"Name": "PEM-formatted Private Key",
"Regex": "^(-----BEGIN( ANY| RSA| DSA| ENCRYPTED| EC| OPENSSH)? PRIVATE KEY-----\\n?[a-zA-Z0-9\\/\\.\\n\\:\\+\\=]+-----END( ANY| RSA| DSA| ENCRYPTED| EC| OPENSSH)? PRIVATE KEY-----)$",
"plural_name": false,
"Description": "Textual encoding of Public-Key Cryptography Standards (PKCS) described in RFC7468. Some of these PEM headers are defined in OpenSSL in https://github.com/openssl/openssl/blob/master/include/openssl/pem.h",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@amadejpapez Do you think we need this description?

Copy link
Copy Markdown
Collaborator

@amadejpapez amadejpapez Oct 7, 2021

Choose a reason for hiding this comment

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

I don't think so. If a user wants to get this additional info they can easily search for it. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should i change it or what should i do? sorry first time contributing, don't know how to proceed 🙂

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi! We think it is not needed, so you can remove it yes. Replace it with null :)

"Rarity": 1,
"URL": null,
"Tags": [
"Credentials"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we add the tag "Bug Bounty" here too please?

The regex will match private key generated by ssh-keygen and those
defined by OpenSSL header file. The regex, however, doesn't validate if
the string within BEGIN and END label is "correct" Base64 encoded. As it
can be validated be direct checking with the public key

Resolves: bee-san#174
@bee-san bee-san enabled auto-merge (squash) October 8, 2021 08:33
@bee-san bee-san merged commit 005516a into bee-san:main Oct 8, 2021
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

Successfully merging this pull request may close these issues.

Add Regex from sshGit

3 participants