[LOW] Redact private JWK material from inspection - #754
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
OskarEichler
force-pushed
the
codex/security-redact-jwk-inspection
branch
from
September 4, 2026 16:33
7d1d608 to
fbb25d2
Compare
anakinj
reviewed
Sep 5, 2026
| end | ||
|
|
||
| def pretty_print(pp) | ||
| pp.text(inspect) |
Member
There was a problem hiding this comment.
pp is not a dependency of the gem so i would drop this method.
anakinj
reviewed
Sep 5, 2026
| end | ||
|
|
||
| def inspect | ||
| "#<#{self.class} @parameters=#{export.inspect}>" |
Member
There was a problem hiding this comment.
A spec to test this would be useful. also maybe not claim @parameters equals the exported value as its not really true.
Member
|
@OskarEichler This looks promising. Could you take a look at my comments and adjust? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevents routine inspection and pretty-printing of JWK objects from exposing private cryptographic parameters. This addresses finding 4 in #723.
Problem
Ruby's default object inspection includes instance variables.
JWT::JWK::KeyBasestores complete JWK parameters in@parameters, including:kd,p,q,dp,dq, andqidLogging, debugging, or pretty-printing a private JWK therefore emits private key material.
Fix
Implement
inspectandpretty_printinKeyBaseusing each concrete JWK type's existing defaultexport. That export already retains public metadata while omitting private cryptographic parameters.Verification
inspectandPP.ppbundle exec rspec: 557 examples, 0 failures, 12 expected pendingbundle exec rubocop lib/jwt/jwk/key_base.rb: no offensesNo test files are included in this focused patch. The behavior was verified with an external reproduction plus the complete existing suite.
Compatibility
The textual representation of JWK objects changes. Public JWK parameters remain visible; private cryptographic parameters no longer do. No runtime signing, verification, import, or export API behavior changes. No breaking change intended.