Skip to content

fix(polynonce): reject unsupported degree parameter#28

Open
oritwoen wants to merge 1 commit intomainfrom
fix/polynonce-degree-validation
Open

fix(polynonce): reject unsupported degree parameter#28
oritwoen wants to merge 1 commit intomainfrom
fix/polynonce-degree-validation

Conversation

@oritwoen
Copy link
Owner

PolynonceAttack::new(degree) accepted any value, but the elimination polynomial math is hardcoded for linear nonce relationships (degree=1). Setting --degree 2 would loosen the detection filter without actually implementing quadratic recovery, so the tool would report vulnerabilities it can't exploit.

Constructor now panics on degree != 1, and the CLI validates before construction with a proper error message.

Closes #20

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

Warning

Rate limit exceeded

@oritwoen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a49eb371-9137-4691-acde-30b9ecdb60d9

📥 Commits

Reviewing files that changed from the base of the PR and between 4197b9b and cf0b08a.

📒 Files selected for processing (2)
  • src/attack/polynonce.rs
  • src/main.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/polynonce-degree-validation
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/polynonce-degree-validation
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 3/5

  • There is a concrete user-facing regression risk in src/attack/polynonce.rs: a public constructor now panics on invalid input, which can abort downstream applications instead of returning a recoverable error.
  • Given the issue’s medium severity (6/10) and high confidence (9/10), this is more than a minor cleanup concern and adds meaningful merge risk.
  • This is likely fixable before release by restoring error-based validation for public API misuse, which would make the change safer for library consumers.
  • Pay close attention to src/attack/polynonce.rs - public constructor input handling currently converts caller mistakes into panics.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/attack/polynonce.rs">

<violation number="1" location="src/attack/polynonce.rs:18">
P2: This public constructor now panics on invalid input. That is fine for a private invariant, but here it turns a caller mistake into a process abort for library users instead of a normal error.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant User as User / CLI
    participant Main as Main::run()
    participant Attack as PolynonceAttack

    User->>Main: Execute "polynonce" attack
    
    Note over Main,Attack: Validation Boundary
    
    alt NEW: degree != 1
        Main-->>User: NEW: anyhow::bail! (Error message)
    else degree == 1 (Supported)
        Main->>Attack: NEW: new(degree)
        Note right of Attack: CHANGED: Constructor now<br/>asserts degree == 1
        Attack->>Attack: NEW: assert!(degree == 1)
        
        Main->>Attack: detect(signatures)
        Attack-->>Main: List of vulnerabilities
        Main-->>User: Report results
    end
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


impl PolynonceAttack {
pub fn new(degree: usize) -> Self {
assert!(
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 15, 2026

Choose a reason for hiding this comment

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

P2: This public constructor now panics on invalid input. That is fine for a private invariant, but here it turns a caller mistake into a process abort for library users instead of a normal error.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/attack/polynonce.rs, line 18:

<comment>This public constructor now panics on invalid input. That is fine for a private invariant, but here it turns a caller mistake into a process abort for library users instead of a normal error.</comment>

<file context>
@@ -15,6 +15,10 @@ pub struct PolynonceAttack {
 
 impl PolynonceAttack {
     pub fn new(degree: usize) -> Self {
+        assert!(
+            degree == 1,
+            "only linear polynonce (degree=1) is implemented, got degree={degree}"
</file context>
Fix with Cubic

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.

bug: PolynonceAttack accepts degree>1 but only implements linear elimination

1 participant