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

Project full of JWT keys (hexadecimal) #775

Closed
szepeviktor opened this issue Jul 2, 2023 · 7 comments
Closed

Project full of JWT keys (hexadecimal) #775

szepeviktor opened this issue Jul 2, 2023 · 7 comments

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Jul 2, 2023

There are projects full of hexadecimal strings.
For example https://github.com/web-auth/webauthn-framework/blob/69c7a1635750a15c7b32891f0d123fb5fccacf74/tests/library/Unit/AttestationStatement/AndroidKeyAttestationStatementSupportTest.php#L91

Related to #32

How to deal with them?
I hope I should not exclude all files with hexadecimal strings :)

@szepeviktor
Copy link
Contributor Author

Could it be a simple ' versus " issue?

@epage
Copy link
Collaborator

epage commented Jul 3, 2023

I'm not noticing any hexadecimal values in that code.

I do see

        $input = '{"rawId":"AZD7huwZVx7aW1efRa6Uq3JTQNorj3qA9yrLINXEcgvCQYtWiSQa1eOIVrXfCmip6MzP8KaITOvRLjy3TUHO7_c","id":"AZD7huwZVx7aW1efRa6Uq3JTQNorj3qA9yrLINXEcgvCQYtWiSQa1eOIVrXfCmip6MzP8KaITOvRLjy3TUHO7_c","response": {"clientDataJSON":"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiVGY2NWJTNkQ1dGVtaDJCd3ZwdHFnQlBiMjVpWkRSeGp3QzVhbnM5MUlJSkRyY3JPcG5XVEs0TFZnRmplVVY0R0RNZTQ0dzhTSTVOc1pzc0lYVFV2RGciLCJvcmlnaW4iOiJodHRwczpcL1wvd2ViYXV0aG4ub3JnIiwiYW5kcm9pZFBhY2thZ2VOYW1lIjoiY29tLmFuZHJvaWQuY2hyb21lIn0","attestationObject":"o2NmbXRrYW5kcm9pZC1rZXlnYXR0U3RtdKNjYWxnJmNzaWdYRjBEAi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V5c3RvcmUgU29mdHdhcmUgQXR0ZXN0YXRpb24gUm9vdDAeFw0xNjAxMTEwMDQzNTBaFw0zNjAxMDYwMDQzNTBaMIGYMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEVMBMGA1UECgwMR29vZ2xlLCBJbmMuMRAwDgYDVQQLDAdBbmRyb2lkMTMwMQYDVQQDDCpBbmRyb2lkIEtleXN0b3JlIFNvZnR3YXJlIEF0dGVzdGF0aW9uIFJvb3QwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATuXV7H4cDbbQOmfua2G-xNal1qaC4P_39JDn13H0Qibb2xr_oWy8etxXfSVpyqt7AtVAFdPkMrKo7XTuxIdUGko2MwYTAdBgNVHQ4EFgQUyK3pd0xFw6PPDRYQ5HlDOiFaMM8wHwYDVR0jBBgwFoAUyK3pd0xFw6PPDRYQ5HlDOiFaMM8wDwYDVR0TAQH_BAUwAwEB_zAOBgNVHQ8BAf8EBAMCAoQwCgYIKoZIzj0EAwIDRwAwRAIgNSGj74s0Rh6c1WDzHViJIGrco2VB9g2ezooZjGZIYHsCIE0L81HZMHx9W9o1NB2oRxtjpYVlPK1PJKfnTa9BffG_aGF1dGhEYXRhWMWVaQiPHs7jIylUA129ENfK45EwWidRtVm7j9fLsim91EUAAAAAKPN9K5K4QcSwKoYM73zANABBAVUvAmX241vMKYd7ZBdmkNWaYcNYhoSZCJjFRGmROb6I4ygQUVmH6k9IMwcbZGeAQ4v4WMNphORudwje5h7ty9ClAQIDJiABIVggOEmiD94mw0sAiDkaWCd4Pf-TiAsWVAiKrfr1eiWVSaEiWCB0PEtSRc8mhc-RBUNnzU-vuUhOcFk2UQEfwNzOdiHGjw"},"type":"public-key"}';

which I'm assuming is some kind of base64 encoded value. We do support base64 but only when it has padding.

Some related issues

Those have a mixture of symptoms and potential solutions in them. I'd recommend checking them out in case some of the discussion would be relevant for your case depending on what type of content you are dealing with and how it can be detected.

One thing that is implemented today is the ability to define a regex to describe patterns that typos does not currently support detecting. This can especially work well when heuristics are involved that might not be appropriate for typos. If there is enough information to detect the content and its general enough (which I feel like JWTs would be) then we can support it.

@szepeviktor
Copy link
Contributor Author

Thank you!
TOML does not allow braces :(

TOML parse error at line 27, column 20
   |
27 | extend-ignore-re = ["'{\"id\":\".+}'"]
   |                    ^^^^^^^^^^^^^^^^^^^
regex parse error:
    '{"id":".+}'
      ^
error: repetition quantifier expects a valid decimal
TOML parse error at line 27, column 25
   |
27 | extend-ignore-re = ["'\{\"id\":\".+\}'"]
   |                         ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Jul 3, 2023

Putting those braces into brackets tricks TOML ❕

[default]
extend-ignore-re = ["'[{]\"id\":\".+[}]'"]

@szepeviktor
Copy link
Contributor Author

szepeviktor commented Jul 3, 2023

'[{".+"}]' literal brackets are really impossible to turn into TOML.

@epage
Copy link
Collaborator

epage commented Jul 3, 2023

You could take advantage of multi-line string literals: https://toml.io/en/v1.0.0#string

@szepeviktor
Copy link
Contributor Author

[default]
extend-ignore-re = [
    "'\\{\"id\":\".+\\}'",
    "'\\[\\{\".+\"\\}\\]'"
]

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

2 participants