liveBook · Manning

Data integrity

As explained in Software Security for Developers

Integrity is the property that data or a message remains accurate and unaltered during transmission or storage.

Data integrity means that data or a message remains accurate and unaltered during transmission or storage. A browser request can be changed by network faults or interception, while a database record can be damaged or modified. Integrity is distinct from authentication, confidentiality, and nonrepudiation: it answers whether the data changed, not who sent it or who can read it. section 4.1

Choose the protection according to the failure or attack you must detect:

  • A cryptographic hash such as SHA-2 or SHA-3 produces a fixed-size, deterministic value. Comparing the stored and recalculated values detects accidental corruption, but an attacker who changes both the data and hash can evade detection. section 4.7 section 4.8
  • A message authentication code, commonly HMAC, combines the message with a secret shared by sender and receiver. A matching value supports both integrity and authenticity because an attacker cannot generate a valid value without the key. section 4.5 section 4.7
  • JWS packages signed data, integrity information, and signing metadata in one file. The recipient can verify the creator and detect alteration, while the readable header and payload remain unencrypted. section 11.4.3

Refund processing

Suppose a warehouse application sends refunds.json to a payments service. A plain SHA-256 checksum can reveal accidental corruption, but an attacker can replace both files and alter a refund amount. HMAC lets the payments service reject modified data because the attacker lacks the shared secret. JWS can package the refund payload and its signature into refunds.jws; changing the secret or file content causes verification to fail and the payment service to reject the file. section 4.7 section 11.4.3

Figure 4.1 A typical high-level e-commerce architecture. Customers place orders using ACME’s web applications, which call the Payments, Inc. credit card API to collect payment while processing an order.
figure

Trace integrity requirements across the browser, e-commerce application, and payment API in a typical request flow. section 4.1

How Software Security for Developers covers it

How deep it goes
Defines integrity, contrasts hashes with HMAC and JWS, and demonstrates verification and rejection without covering cryptographic proofs.
Examples
Uses browser requests, database records, checksums, refunds.json, HMAC, and refunds.jws to illustrate corruption and tampering.
What it assumes
Assumes basic application and message-flow knowledge while introducing cryptographic hashes, shared secrets, MACs, and message authentication from practical scenarios.
What you can do after
Evaluate integrity mechanisms and apply hashes, HMAC, or JWS according to corruption, tampering, and authenticity requirements.
How it connects
Connects cryptographic hash functions, authentication, HMAC, message authentication codes, JWS, confidentiality, and nonrepudiation.

Also explained in

Compare how 18 books explain data integrity →

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.