crypto: fix unsigned conversion of 4-byte RSA publicExponent#62839
crypto: fix unsigned conversion of 4-byte RSA publicExponent#62839deepview-autofix wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
There was a problem hiding this comment.
This is mine (scanner + autofixer)
bigIntArrayToUnsignedInt was, in fact, signed prior to the fix, and returned negative values for half of the accepted input range.
That happens on 4 significant byte input and is currently only reachable through RSA-OAEP publicExponent which is usually at most 3 significant bytes (Chrome even only allows two specific values), so real impact should be non-existent.
It should still be fixed to return unsigned values (especially if something new starts using it as this is an per-standard input parsing helper).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62839 +/- ##
==========================================
- Coverage 89.62% 89.61% -0.02%
==========================================
Files 706 706
Lines 219136 219136
Branches 41987 41985 -2
==========================================
- Hits 196404 196373 -31
- Misses 14611 14656 +45
+ Partials 8121 8107 -14
🚀 New features to boost your workflow:
|
|
@ChALkeR please align the first commit message with that of the PR |
c70083c to
b1f8d08
Compare
|
@panva done, also squashed. |
|
Please note that i'm not sure having an agent author your PRs is valid per #62577 |
|
@panva The commit is signed off by me, not by the agent. (Also technically it wasn't PRd by an agent, it was PRd by a simple script after approval, the agent is isolated in a VM and only produces a patch and does not have credentials to commit it, it was long terminated together with the VM at the commit time). As for an agent - it is the main co-author, and I think that labelling that explicitly instead of hiding it is valuable. |
|
|
... that's not how signed-off-by is supposed to work. Compare for example with DCO: https://developercertificate.org/ Commented: #62577 (comment) |
|
@panva This is the setup:
I do not think that (3) makes me the main author. |
|
@ChALkeR that's for a discussion elsewhere I believe. But note that this discussion applies to all the PRs opened by @deepview-autofix today. |
That is my intention. It is my pipeline that auto-detects logic mistakes and then (upon manual confirmation) feeds them to the autofixer-in-vm. But the original code issue is auto-detected. I think it should be explicit in the changelog and that preserving that in the record has value. |
That may be the case but the guidelines that may (or may not?) end up being adopted for AI contribution explicitly don't align with this.
|
|
The project has no way to discern or confirm that, neither do the reviewers. I think for now it's better if the PRs and their commits come authored by you and attribute your tooling with Assisted-by trailers. |
I can confirm that (and Signed-off-by explicitly means that). Without trusting contributors the project has no way to confirm anything at all. These lines are more relevant though: https://github.com/nodejs/node/pull/62105/files#diff-042367f42be04fc3f4bcf7442f7a24183e207dc1ab552492f8a528904dd5d770R19-R21 Hm. |
|
Hm. The OpenJSF policy (at https://openjsf.cdn.prismic.io/openjsf/aca4d5GXnQHGZDiZ_OpenJS_AI_Coding_Assistants_Policy.pdf) specifies So, per policy, at least the Unsure about the deepview-autofix line. It's a pipeline: detection -> confirmation -> agent in vm (but that's the Claude line) generating a fix -> confirmation -> commit -> confirmation -> PR. I'll try to think of a better way to signal that... |
|
@panva For now, until the policies are finalized, I'll manually switch to this format: This is indeed reasonable as the whole pipeline is manually-reviewed at many points. Wdyt? |
|
Wouldn't that at odds with this?
And non-humans can't have a signed-off-by, that would mean all your assistants should be assisted-by. Which leaves: I see the points behind your motivation (or the motivation behind your points) for attributing the tooling but from the POV of the project we accept/look for contributions from a |
|
@panva good catch. #62577 (comment) (I don't think that this should create an incentive to obscure code origin and remove co-authored-by from agents). |
c3cbd20 to
09d2cb7
Compare
`bigIntArrayToUnsignedInt` used the signed `<<` operator, so when the most significant byte of a 4-byte input had its top bit set (e.g. `[0x80, 0x00, 0x00, 0x01]`) the result was a negative Int32 instead of the intended unsigned 32-bit value. This caused any RSA `publicExponent` exactly 4 bytes long with the top bit set to be parsed incorrectly. Coerce the final value with `>>> 0` and add a unit test. Assisted-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com> Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com> Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
09d2cb7 to
a6aa86c
Compare



bigIntArrayToUnsignedIntused the signed<<operator, so when the most significant byte of a 4-byte input had its top bit set (e.g.[0x80, 0x00, 0x00, 0x01]) the result was a negative Int32 instead of the intended unsigned 32-bit value. This caused any RSApublicExponentexactly 4 bytes long with the top bit set to be parsed incorrectly. Coerce the final value with>>> 0and add a unit test.