liveBook · Manning

Data corruption

As explained in Software Security for Developers

Data corruption is unintended alteration or loss of stored or transmitted data that makes it differ from its correct contents.

Data corruption is the unintended alteration or loss of data, causing it to differ from its correct contents. In a refund workflow, processing a corrupted refunds.json file could send the wrong amount to the wrong credit card. section 4.2

A cryptographic hash detects accidental corruption by producing repeatable output for the same input. The producer stores a file and its hash; the consumer recomputes the hash and compares both values before processing the file. section 4.2.2

Use this validation sequence:

  • Compute the SHA-256 hash of refunds.json. section 4.2.2
  • Compare the computed value with refunds.json.sha256. section 4.2.2
  • Process the file only when the values match; otherwise raise an error and issue no refunds. section 4.2.2

Refund upload

A Java payment endpoint receives the file and a hash header, rejects a missing or mismatched hash, and parses the refunds only after validation. Changing refunds.json without recalculating its hash triggers an exception. section 4.4

Figure 4.2 ACME staff members approve refunds using the warehouse management application. Once a day, the application generates a refunds.json file. The payment service refunds customer credit cards for the amount specified in that file.
figure

Trace the warehouse application’s refunds.json handoff to the payment service and identify where integrity validation belongs. section 4.2

How Software Security for Developers covers it

How deep it goes
Explains hash generation, comparison, rejection, and accidental-failure limits, but defers active-tampering protection.
Examples
Uses refunds.json, sidecar hash files, Maven Central artifacts, Git commits, and a Java refunds endpoint.
What you can do after
Diagnose accidental file corruption by recomputing a hash and rejecting mismatched content.
How it connects
Connects data corruption with cryptographic hash functions, message integrity, HMACs, and active tampering.

Also explained in

Compare how 3 books explain data corruption →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.