Course contentsShow
← Security
Lesson 1293 of 3,05226. Application Security - Supply ChainFree lesson

Package Integrity and Checksums

Understanding how checksums, hashes, and signatures verify package integrity during download and installation.

Package Integrity and Checksums

What you'll learn: How checksums, hashes, and signatures ensure that downloaded packages haven't been tampered with during transit or storage.

The Problem: Trust in Package Delivery

When you download a software package from the internet, you face a critical question: Is this exactly what the publisher intended, or has someone modified it? An attacker could intercept your download, inject malware, and serve you a compromised version. Without verification, you'd have no way to know.

How Package Integrity Works

Package managers use cryptographic hashes (like SHA-256 or SHA-512) to verify package integrity. Think of a checksum like a unique fingerprint for a file—even a single changed byte produces a completely different hash.

Here's the typical flow:

  1. Publisher generates hash: When a package author publishes version 1.2.3, they create a cryptographic hash of the package file
  2. Hash stored separately: This hash is saved in a lock file, repository metadata, or signature file
  3. Download and verify: When you install the package, your package manager downloads it, computes its hash, and compares it to the expected value
  4. Match = safe: If hashes match, the package is authentic and unmodified; if not, installation fails

Beyond Checksums: Digital Signatures

While checksums detect changes, digital signatures prove authenticity—that the package truly came from the claimed publisher. Signatures use public-key cryptography, where publishers sign packages with their private key, and you verify with their public key.

Key Takeaway: Checksums and hashes verify package integrity by ensuring downloaded files match expected cryptographic fingerprints, protecting against tampering and corruption during the supply chain. Always use package managers that verify integrity automatically, and inspect lock files containing these hashes.