BaCheWork and records of a photonics research workhorse
Language

Two moves only dynamic sites need: checking against the server’s own time, and leaving the original data alone

A site that quotes prices, takes orders or has a database carries two extra risks: someone may submit an order with stale or edited prices, and queries may hit the original data directly. This post starts from two directions raised in a friends’ group chat and adds implementation steps based on OWASP’s recommendations: prices and times are decided by the server, the original data is kept as a separate copy, and queries touch only the copy.

Type
Essay
Published
2026-11-22
Updated
2026-11-22

The first six chapters are mostly about static sites. My site has no shopping cart and no member data, and I have not implemented either of these two moves myself. They started from a discussion in a friends’ group chat. I organized the direction of that discussion and added implementation steps based on OWASP’s recommendations (OWASP is an open community that compiles website security practices), as a starting point for people building dynamic sites. Below, I note separately what came from the group and what I added.

First, be clear: there is no “this makes it safe”

The friend who raised the first move added, roughly, that this is only “relatively safe,” not that doing this makes you safe. That caveat is the most important premise of this chapter. The two moves below only reduce the chance of casual trial and error; they will not stop a determined attacker, and I have not tested them.

1. Judge using the server’s own time and data

Scenario: the price shown on the page is five minutes old, the price has since been updated, but someone still submits an order from the old page. Or worse: someone edits the price field in the submission to be lower.

Principle: do not trust the price and time sent by the browser. OWASP’s guide to testing payment functions states this clearly: the request the browser sends to the server should contain only the product ID and quantity, with all prices handled on the server side. Its guide to business logic security also gives an example: a checkout flow validated the format of every field, but the total was recalculated from the unit price sent by the browser, and someone bought a TV for one cent.

What the group discussed was the direction: use the server’s own absolute time as the baseline to compare how fresh the data is. For example, once the price has been updated, a price from five minutes ago can no longer be used to order. The skeleton below is what I added based on OWASP’s recommendations; it is not the friend’s original wording.

Skeleton of the approach:

  1. When the server issues a quote, it records the quote itself: an ID, the price, the time it was issued according to the server’s clock, and when it expires.
  2. The page receives only the quote ID and the price for display.
  3. When ordering, the browser sends only the quote ID and the quantity.
  4. The server checks against its own clock that the quote has not expired, then calculates the amount using the price it stored. If it has expired, reject it and ask the user to refresh.
  5. Each quote ID can be used only once; record it once it is used.

The last step is there to guard against replay: the same request being sent again unchanged. OWASP’s Webhook security guide recommends using a time tolerance together with “recording event IDs that have already been processed”; its business logic security guide also recommends that once a one-time step is completed, it is recorded, and repeating that step counts as an error.

What my friend called the “heartbeat” is the server having a trusted time reference of its own, which is used to identify expired data. He also mentioned using multiple verification methods, and letting a request through only when all of them pass.

2. Leave the original data untouched; queries touch only a copy

The other direction in the group was my suggestion: set up a separate database that stores a copy in an adjusted format, so the original data is left completely untouched and uninvolved, and the two are kept more clearly apart.

  • Keep the original data intact: for example, price records, stored exactly as they are.
  • Prepare a separate copy for queries: the time is the same, and the original recording method and source remain in the original data; the copy organizes it into metadata or tags, and queries run in SQL.
  • My extended idea: the website and the AI assistant touch only the copy and never modify the original data directly. If the copy breaks or gets altered, rebuild it from the original data.

This matches the “least privilege” direction of OWASP’s database security guide, which recommends that each application or service have its own database account with only the permissions it needs. “The query layer gets read-only access” is a practice I derived from this principle; the guide does not say it that way.

The cost: you have to maintain the “original data → copy” pipeline, and the copy will lag slightly. For a site where prices do not need to update in real time, this cost is usually acceptable.

When this chapter applies

Your site Do you need it?
Purely static portfolio or blog Not needed; the first six chapters are enough
Shows prices but cannot take orders The second move is worth doing (protects the original data)
Takes orders and payments At least these two moves are needed, and it should also be reviewed by a professional

Security for dynamic sites goes much deeper than this chapter: login and sessions, permissions, injection attacks, payment flows, and so on, and each of these could be a whole series. This chapter offers just two good starting points.

Sources

  1. OWASP WSTG: Payment Functionality (OWASP)
  2. OWASP Cheat Sheet: Business Logic Security (OWASP)
  3. OWASP Cheat Sheet: Webhook Security (replay and time limits) (OWASP)
  4. OWASP Cheat Sheet: Database Security (least privilege) (OWASP)

← Previous:Keep the protections from silently failing: one checklist plus periodic re-checks