download

A dependency upgrade passed CVE scans. Why can security still break?

Security~10 minReviewed 2 Dec 2026Free · No sign-in

Question

You upgrade a Python helper library that unpacks uploaded .tar bundles into a sandbox folder. pip-audit and CVE scanners report zero advisories, and unit tests pass on normal files like report.txt. Yet the new version quietly changed its default to permissive extraction (filter="fully_trusted").

  1. Why do version numbers and CVE scanners miss this regression?
  2. Write an automated security regression check on synthetic .tar fixtures (report.txt, ../escape.txt, and an escaping symlink) that fails if anything extracts outside dest.
"CODE · PYTHON"
import tarfile


def unpack_bundle(tar_buf, dest):
    # Wrapper default changed during a dependency upgrade.
    with tarfile.open(fileobj=tar_buf) as tf:
        tf.extractall(dest, filter="fully_trusted")
Show hints (3)
  1. "CVES VERSUS DEFAULTS"

    Advisory tools match known package CVEs. They cannot tell whether a clean release flipped a default like redirect following or symlink handling.

  2. "BUILD SYNTHETIC FIXTURES"

    Create tiny in-memory .tar buffers inside a temp folder: a normal file, a ../escape.txt entry, and a symlink pointing outside dest.

  3. "ASSERT THE BOUNDARY"

    Pass explicit safe options (filter="data"), assert that escaping entries raise tarfile.FilterError, and check that the parent folder stays clean.

Show checked explanation

Version checks and CVE scanners like pip-audit or npm audit only match known advisories. They miss a clean upgrade that flips a default like path filtering or redirect following. Set safe options explicitly (filter="data"), and run an automated regression test on synthetic bad fixtures that fails if anything writes outside dest.

"SOLUTION · PYTHON"
import io
import os
import tarfile as tf
import tempfile

def probe(name, flt="data", link=""):
    buf = io.BytesIO()
    with tf.open(fileobj=buf, mode="w") as z:
        ti = tf.TarInfo(name)
        ti.type, ti.linkname = (tf.SYMTYPE, link) if link else (tf.REGTYPE, "")
        z.addfile(ti)
    with tempfile.TemporaryDirectory() as r:
        try:
            with tf.open(fileobj=io.BytesIO(buf.getvalue())) as z:
                z.extractall(os.path.join(r, "out"), filter=flt)
            return "escaped" if set(os.listdir(r)) - {"out"} else "ok"
        except tf.FilterError as err:
            return type(err).__name__
print(probe("report.txt"), probe("../escape.txt"), probe("l", "data", "../s"))
print("unfiltered:", probe("../escape.txt", "fully_trusted"))
"OUTPUT"
ok OutsideDestinationError LinkOutsideDestinationError
unfiltered: escaped

Code run on CPython 3.12.10 with stdlib tarfile on synthetic safe, traversal, and symlink archives in temporary folders; official OWASP, Python tarfile, and npm audit links checked. Checked by an editor other than the author.

Walkthrough

Dependency scanners (pip-audit, npm audit, SCA tools) compare your lockfile versions against public CVE databases. A new major release that flips a default is often an intentional API change, not a CVE, so every advisory check stays green. Happy-path unit tests (report.txt) stay green too.

Only a behavioral security regression test catches the break. In probe above, Python builds tiny synthetic .tar archives in memory inside an isolated temporary directory:

  • report.txt extracts inside out and returns ok.
  • ../escape.txt raises OutsideDestinationError under filter="data", leaving the parent folder clean.
  • Symlink l -> ../s raises LinkOutsideDestinationError before any link is written.
  • Switching flt to "fully_trusted" writes outside out so set(os.listdir(r)) - {"out"} catches any escaping filename (unfiltered: escaped), immediately failing CI.

The same testing rule applies across every security-sensitive library you upgrade:

library upgradesilent default changesynthetic regression test in CI
Archive extractorRelaxes .. or symlink filteringUnpack synthetic ../escape.txt and outside symlink; assert error and clean parent dir
HTTP / URL clientFollows 302 redirects or keeps Authorization cross-originHit local test 302 to disallowed host; assert redirect blocked or header stripped
HTML sanitizerAllows extra tags or javascript: URLsPass synthetic risky HTML fixture; assert dangerous tags and schemes are removed

Pair this with explicit safe configuration (filter="data", allow_redirects=False) so your safety guarantee never rests on an implicit library default.

Common mistakes

  • Treating a clean pip-audit or npm audit report, or a bumped version number, as proof that an upgrade kept your security guarantees intact.
  • Relying on implicit library defaults instead of passing explicit options like filter="data" or allow_redirects=False in your wrapper.
  • Testing only happy-path fixtures like report.txt on upgrade PRs, which never exercise path traversal, symlinks, or cross-origin redirects.
  • Asserting only that a helper "did not crash" instead of checking that the escaping file was rejected and never created outside dest.

Follow-up questions

  • "An HTTP client upgrade turned on automatic redirect following. How would you write a fast CI test for it?" Spin up a tiny local test server on 127.0.0.1 that returns 302 to a disallowed target or second origin. Call your HTTP wrapper with a synthetic Authorization: Bearer test_tok header and assert that either redirects are refused or the header is stripped on the second hop.
  • "Should you stop running pip-audit, npm audit, or CVE scanners if you have security regression tests?" No, because they catch different failures. Advisory scanners flag known CVEs in transitive packages you never wrote tests for. Regression tests confirm that your app's own security boundaries still hold after every upgrade.
  • "How do you avoid flaky or risky security tests in CI?" Use tiny self-contained synthetic fixtures in memory or temporary folders, and bind any local HTTP test server to loopback (127.0.0.1). Never point tests at real secrets, real user data, or external hosts.

What a strong answer covers

Explains why version pins and CVE scans miss default-behavior regressions. Sets explicit safe options and writes fast CI tests on synthetic fixtures that directly assert the defense holds.

Open in interactive practice deck →

Original OfferVibe question. OWASP Vulnerable Dependency Management Cheat Sheet · Python tarfile extraction filters · npm audit docs.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.