GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] InsecureCryptoIv: False negative with fixed IVs from array initializers · Issue #6531 · pmd/pmd

[java] InsecureCryptoIv: False negative with fixed IVs from array initializers #6531

New issue
Copy link
New issue
Copy link
Closed
#6545
Closed
[java] InsecureCryptoIv: False negative with fixed IVs from array initializers#6531
#6545
Copy link
Labels
a:false-negativePMD doesn't flag a problematic piece of code
Milestone
7.23.0

Description

@Carlson-JLQ
Carlson-JLQ
opened on Mar 23, 2026
Issue body actions

Rule: InsecureCryptoIv

False Negative: Fixed IVs are no longer tracked once they are moved into fields or helpers.

Version
7.22.0

Checker

  • Checker id: category/java/security.xml/InsecureCryptoIv
  • Checker description: This rule detects insecure usage of hardcoded initialization vectors (IVs) in cryptographic operations by checking for direct instantiation of IvParameterSpec with constant arguments.

Description of the false negative

diff/output marks 1 false negatives for category/java/security.xml/InsecureCryptoIv. Across these samples, the benchmark is still exercising the same underlying bug pattern, but the implementation appears to lose track of it once the source deviates from one canonical shape. The misses read more like matching gaps than deliberate exclusions.

Affected test cases

PosCase1.java

Source: output/codeql/StaticInitializationVector/src/main/java/scensct/core/pos/PosCase1.java

The sample keeps the benchmark's target pattern but expresses it in a slightly non-canonical source form. The risky pattern is still present in the code, so the absence of a report points to a matching gap rather than a benign variant. That is also how the benchmark classifies the sample: A method creates a byte array initialized with compile-time constants and passes it as IV to Cipher.init should be flagged as predictable IV.

// A method creates a byte array initialized with compile-time constants and passes it as IV to Cipher.init should be flagged as predictable IV.
package scensct.core.pos;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;

public class PosCase1 {
    public void encrypt() throws Exception {
        // Static byte array initialization with constants
        byte[] iv = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
        Key key = new SecretKeySpec(new byte[16], "AES");
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        // IV passed directly to Cipher.init
        cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv)); // [REPORTED LINE]
    }
}

Cause analysis

The rule is documented as follows: This rule detects insecure usage of hardcoded initialization vectors (IVs) in cryptographic operations by checking for direct instantiation of IvParameterSpec with constant arguments.

The missed cases suggest that the implementation is narrower than the rule description and too dependent on one preferred AST shape.

Once the same behavior is expressed through a helper, an overload, a modifier such as abstract or native, a different comment position, or a slightly rearranged control-flow structure, the report disappears even though the benchmark still treats the case as in-scope.

For category/java/security.xml/InsecureCryptoIv, the practical improvement would be to generalize the match so it follows the underlying behavior rather than one exact spelling of it.

References

None known.

Activity

  1. Carlson-JLQ
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    on Mar 23, 2026
  2. adangel
    changed the title [-]False Negative: Fixed IVs are no longer tracked once they are moved into fields or helpers.[/-] [+][java] InsecureCryptoIv: False negative with fixed IVs from fields or helpers[/+] on Mar 27, 2026
  3. adangel commented on Mar 27, 2026

    @adangel
    adangel
    on Mar 27, 2026
    Member
    More actions

    @Carlson-JLQ Please use the issue templates we provide the next time. This ensures, that only one problem is reported per issue and it's easier to read. Thanks!

  4. adangel
    changed the title [-][java] InsecureCryptoIv: False negative with fixed IVs from fields or helpers[/-] [+][java] InsecureCryptoIv: False negative with fixed IVs from array initializers[/+] on Mar 27, 2026
  5. adangel commented on Mar 27, 2026

    @adangel
    adangel
    on Mar 27, 2026
    Member
    More actions

    Note, that the original heading "Fixed IVs are no longer tracked once they are moved into fields or helpers" is wrong - the single test case doesn't show a problem with fields or helpers. It only uses a local variable. If there are different false negatives, please report them separately.

  6. adangel
    added a commit that references this issue on Mar 27, 2026

    [doc] Update release notes (#6531, #6545)

    5dbbe19
  7. adangel
    closed this as completedin 127df3aon Mar 27, 2026
  8. adangel
    added a commit that references this issue on Mar 27, 2026

    [java] Fix pmd#6531: False negative in InsecureCryptoIv with array in…

    This issue will close once commit 127df3a is merged into the 'main' branch.
    127df3a
  9. adangel
    added this to the 7.23.0 milestone on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-negativePMD doesn't flag a problematic piece of code

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.23.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.