Skip to content

False positive found private key error #1147

Closed

Description

Hi,
a new error is being reported during our build since the introduction of #1144.

Image

The process reports that it found a private key, but it's actually just a hard-coded string coming from ssh2 keygen.js file.

To give you more context, this is what's triggering the error:

Image

It's coming from this file:

Image

So it seems that this is a false positive since it's not an actual private key being found.

Activity

  1. pflannery commented on May 15, 2025

    @pflannery

    I have the same issue when trying to publish versionlens.

    The false positive is coming from a third party dependency @npmcli/config

      key: new Definition('key', {
        default: null,
        type: [null, String],
        description: `
          A client key to pass when accessing the registry.  Values should be in
          PEM format with newlines replaced by the string "\\n". For example:
    
          \`\`\`ini
          key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
          \`\`\`
    
          It is _not_ the path to a key file, though you can set a registry-scoped
          "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
        `,
        deprecated: `
          \`key\` and \`cert\` are no longer used for most registry operations.
          Use registry scoped \`keyfile\` and \`cafile\` instead.
          Example:
          //other-registry.tld/:keyfile=/path/to/key.pem
          //other-registry.tld/:cafile=/path/to/cert.crt
        `,
        flatten,
      }),
  2. scnwwu commented on May 16, 2025

    @scnwwu

    Same here. In addition, the scan will always be performed even with --allow option. It appears increased the CI time as I have many data files.

  3. benibenj commented on May 16, 2025

    @benibenj
    Contributor

    Thank you for reporting these cases. The private key scanning we are using does not seem to be very smart. I've added some check on top of it which should be able to ignore the false positive cases mentioned above. As soon as the PR is merged, I'll release a patch. Please let me know if this fixed your issues or if you run into other false positives.

  4. ArturoDent commented on May 19, 2025

    @ArturoDent

    [With vsce v3.4.1]

    Here is my use case. I am requiring typescript into a javascript extension.

    const ts = require('typescript');

    so that I can use things like ts.isArrowFunction(node.initializer).

    and have added typescript as a dependency. When I try to publish many "secrets" are flagged like

    ERROR  Potential security issue detected: Your extension package contains sensitive information that should not be published. Please remove these secrets before packaging.
    
      found npm access token: npm_i_save_dev_types_Slash... [npm]
      node_modules\typescript\lib\_tsc.js#6552:84-6552:124
    
      found npm access token: npm_i_save_dev_types_Slash... [npm]
      node_modules\typescript\lib\zh-cn\diagnosticMessages.generated.json#1709:8-1709:48
    

    That first link points to this in the node_modules\typescript\lib\_tsc.js file:

    npm_i_save_dev_types_Slashjest_or_npm_i_
    

    The second error link points to

    npm_i_save_dev_types_Slash_1_if_it_exists
    

    They all seem to be diagnostic message related. I assume these are all false positives?

  5. prakhar-gupta-08 commented on May 20, 2025

    @prakhar-gupta-08

    We are also facing the multiple false positives being reported and failing our build pipelines. Its using the latest version of vsce package:

    Image

  6. dummdidumm commented on May 21, 2025

    @dummdidumm

    Same here, we're blocked from publishing our Svelte for VS Code extension because of false positives inside the TypeScript and prettier packages which are part of our dependencies. It has a false positive on strings like Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig

  7. benibenj commented on May 21, 2025

    @benibenj
    Contributor

    Thanks for reporting the npm false positives. I created a new issue to track this: #1153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions