BytesafeDependency Firewall

Block malware

Evaluate downloaded and published package artifacts for malware findings and block at a chosen confidence level.

The malware selector function evaluates findings from malicious-package intelligence and package-content analysis. It runs where the artifact is available: the download phase for installs and the upload phase for publishes. A version-metadata rule cannot do this.

Two options shape a rule: how weak a finding may be and still match (confidence), and how much the rule waits for before it decides (effort).

Add the rules

In the dashboard, open the firewall, go to Rules, and create a rule:

  • Execution phase: download
  • Selector function: Malware
  • Minimum confidence: Known malware
  • Effort: Known findings only
  • Effect: block and log

If the firewall receives publishes, add the same rule on the upload phase, so infected artifacts cannot enter your own registry through you. That rule is also the best candidate for a higher effort, see Choose the effort.

As JSON:

[
  {
    "id": "block-malware-download",
    "executionPhase": "download",
    "selector": {
      "function": {
        "name": "malware",
        "options": { "minimumConfidence": "known_malware", "effort": "known" }
      }
    },
    "ruleEffect": { "block": true, "log": true },
    "description": "Block malicious artifacts on download"
  },
  {
    "id": "block-malware-upload",
    "executionPhase": "upload",
    "selector": {
      "function": {
        "name": "malware",
        "options": { "minimumConfidence": "known_malware", "effort": "known" }
      }
    },
    "ruleEffect": { "block": true, "log": true },
    "description": "Block malicious artifacts on publish"
  }
]

To apply the JSON without the dashboard: export the config with bsfw config export, add the rules to the rules array, and import it back. See config import.

Choose the confidence level

minimumConfidence is the weakest finding that matches:

Config valueDashboard labelMatches
known_malwareKnown malwareDefinitive findings only. Default when the option is omitted
suspiciousSuspicious or strongerSuspicious and known-malware findings
weak_indicatorAny indicatorEvery finding, including weak indicators

Start with Known malware and a blocking effect. If you lower the threshold, use a log-only rule first to review the additional matches before enabling block.

Choose the effort

effort is how much the rule waits for before it decides:

Config valueDashboard labelThe rule decides onEffect on the request
knownKnown findings onlyFindings that already exist for the artifact: malicious-package intelligence, plus content analysis that has already been done. Default when the option is omittedNothing to wait for
deepWait for deep analysisThe same, and it has the artifact's contents analyzed as part of the request, waiting for that resultSlower. The first request for an artifact nobody has analyzed yet waits for the whole analysis

Effort and confidence are independent. Effort decides how much is known when the rule runs, confidence decides how weak a finding may be and still match.

known is the default, so a rule created without a thought about effort does not hold up installs. deep is the deliberate choice, and worth sizing before you make it: that first analysis can take minutes on a large package. Requests that follow are faster, because the result exists by then.

Publishes are usually the better place to spend that time than installs. A publish is one request by one person who is already waiting for a pipeline, while an install is every developer and every CI job. Set the upload rule to Wait for deep analysis and leave the download rule on Known findings only, and only take the download rule to deep for a firewall where a slow install is acceptable.

{
  "id": "block-malware-upload",
  "executionPhase": "upload",
  "selector": {
    "function": {
      "name": "malware",
      "options": { "minimumConfidence": "known_malware", "effort": "deep" }
    }
  },
  "ruleEffect": { "block": true, "log": true },
  "description": "Block malicious artifacts on publish, after full analysis"
}

What a match looks like

The install fails as a blocked download (see your ecosystem page for the exact client error). The log entry's message identifies the package and finding summary:

Malware detected in <ecosystem>/<package>@<version>: <finding summary>

The rule output carries:

FieldMeaning
malwareFinding summary
scannerDetection source
confidenceknown_malware, suspicious, or weak_indicator
signalsEvidence for the finding, such as a signature or advisory reference

If you believe it is a false positive

Do not disable the rule. Add an exception scoped to the exact package and version, with a short expiry and a reason, and report the package to support@bytesafe.dev so the verdict can be reviewed. An exception on the malware rule does not exempt the package from your other rules, and it stops applying when it expires, so the block returns by itself if the verdict turns out to be correct.

On this page