Build1 publisher3 min readPublished
Treating the database administrator as the attacker moves settlement out of the primary Postgres
Viktor Khudiaiev's reference implementation hands the attacker full admin on the transaction database, then keeps MAC issuance and settlement SQL in separate services on a protected instance. Everything still runs on one Windows host.
The Engineer · Build desk

What happened
- Viktor Khudiaiev published a local reference implementation on dev.to, updated September 20, 2026, built from ordinary PostgreSQL, three Java services and simulated transfers.
- The threat model hands the attacker administrative control of the primary transaction database, with freedom to insert, modify, delete, replay, reorder or restore rows and to disable its triggers.
- The application asks a key service to authenticate each operation and publishes it to primary, and a separate processor verifies candidates and performs settlement.
- Service credentials are split across issuance, verification, key administration and checkpoint signing, giving each service only the right its job needs.
Compiled by The EngineerSomething wrong?How this is made
Why it matters
- capability A retry or a replayed row produces no second financial effect, so the detection property teams usually reach for a distributed ledger to get is available inside a centralized design.
- exposure The host sits inside the trusted set, so the bounded claim holds only while nobody obtains host administrator on the machine running all three services.
- constraint A hostile DBA can still stop the business by destroying the primary database, because the module protects content and settlement state and not availability.
An HMAC combines a secret key with a message, and someone without that key cannot edit the message and recompute the code [6]. The key sits in one service, and the application that publishes operations never receives key bytes or settlement SQL access; the processor that verifies and settles cannot issue new operation MACs [8]. Only the key service can issue a fresh MAC.
Khudiaiev sets out the two boundaries a code on a row cannot cross. An attacker who controls the authoritative balances changes balances directly, and an attacker who controls the service allowed to authenticate new instructions can ask it to authenticate fraudulent instructions [9]. "Adding a MAC column cannot repair either boundary," he wrote [10]. The authoritative execution state therefore lives on the Audit/Protected instance alongside the evidence, with separate runtime roles for issuance, audit and accounting, and the primary administrator cannot modify that protected state [11]. Java computes the debit and the credit, and protected SQL commits them atomically [12].
The claim under test is narrow. With administrative control of the primary database alone, the attacker cannot execute a forged, modified, or already settled operation [13]. A signature over a row does not cover replay. The integration authenticates exact operation content, retains independent evidence before publication, executes only the checked operation, and recovers from retries without repeating the financial effect [14]. For this explicitly centralized trust model, none of those four properties needs distributed consensus.
The demo runs two PostgreSQL instances, and primary is the attacker-controlled one [26]. Khudiaiev says the separate instances and credentials demonstrate the intended access boundaries, but that all services still run on one trusted Windows host where the common administrator can reach every process and secret [15]. Production separation, he writes, requires independent identities, custody and operational ownership, "not merely extra schemas under the same administrator" [16]. His trusted set names six elements against that one hostile database [24]. In my view the result transfers only when the person who can log into your primary cannot log into the host running the key service, and when the protected database has a different operational owner.
"I prefer to begin with a less fashionable question: who can change the database, and what would the application do with those changes?" Khudiaiev wrote [20]. He is explicit about what the module leaves alone. It does not encrypt database contents, prevent destruction of the database, or guarantee availability [18]. Authenticating people and applying business authorization stay with the integrating application, and the integrity module does not establish a human author's entitlement [19]. He introduces no new cryptographic primitive and does not claim to replace every ledger database [17], and describes the work as independent of his employer [23]. "The tests described below exercise that bounded claim; they are not a proof against every possible attack," he wrote [21].
What to watch
- Whether a run with the key service, processor and protected database under separate host identities and custody sustains the same bounded claim.
- Whether the signed checkpoints get anchored outside the trusted set, which would push detection past the single host.
- Whether verify-and-settle latency and throughput are published for the processor path on real transfers instead of simulated ones.