Anti-AIClone

Log date · Mon

Can you protect business logic in an offline app?

Published on · Updated

Hardening raises the cost of analysis, but offline behavior remains observable. We test two ways to probe a pricing function.

The short answer: protect it, but expect observable behavior

You can harden an offline app, but you cannot guarantee that behavior executed on the client stays secret. We wrote an offline quote function and probed its inputs and outputs: 13 coarse calls found four discount rates but placed the 5% threshold at 50; 600 calls, one per quantity from 1 through 600, found all four actual thresholds.

That result does not mean every algorithm can be reconstructed this way. It shows that, even without reading an implementation, a user can record the inputs an app accepts and the results it displays. A protection plan needs to consider disclosure of rules, copied results, licence abuse and the ability of legitimate users to keep working offline.

Results at a glance
QuestionFinding
Does coarse sampling locate exact thresholds?Not always: 5% first appeared at 50; the actual threshold was 20.
What about testing every input?600 calls covered every allowed integer and matched all four thresholds.
Does this prove obfuscation ineffective?No; the test observed the public interface and did not measure obfuscation.

Sample and method

Our synthetic quote function accepts whole quantities from 1 to 600 at a list price of $100 per unit and returns the discounted total in cents. The probe knows the list price and input range, and computes the discount from the returned total. It calls the function interface without reading the sample implementation; the actual table is revealed only after probing. We ran Node.js 20.19.5 on macOS 27.2. This is an interface test of a synthetic pricing function, not an evaluation of a real app or protection product.

The scans count separately. The coarse scan queries 1 and then multiples of 50; the exhaustive scan queries every integer in range. They are independent runs, so the 13 calls are not additional calls in the exhaustive count. A rate is derived from the total, and the first quantity at which we see a rate does not prove where that rate starts.

Probe output from our run.
== coarse (1, then multiples of 50) ==
first observed units=1 discount=0%
first observed units=50 discount=5%
first observed units=100 discount=12%
first observed units=500 discount=22%
calls=13
== exhaustive (1 through 600) ==
first observed units=1 discount=0%
first observed units=20 discount=5%
first observed units=100 discount=12%
first observed units=500 discount=22%
calls=600

In this sample, quantities 20 through 49 never appear in the coarse scan. Seeing 5% at 50 tells us the rate applies there; with 1 as the previous sampled point, the change could have occurred anywhere between them. A coarse scan could miss a short tier altogether if that tier sits entirely between sampled points.

Compare the observations with the real table

After the scans, we read the tiers constant in the sample. “Exhaustive” below means the first quantity at which that rate appeared, not a value extracted from source; it matches the implementation row by row. The implementation selects the first matching threshold in descending order, while the table below is sorted ascending for comparison.

Threshold comparison
DiscountFirst coarse observationFirst exhaustive observationActual minimum
0%111
5%502020
12%100100100
22%500500500
The actual table, output from our run.
const tiers = [[500, 22], [100, 12], [20, 5], [1, 0]];

Six hundred is the call count for this test design, not an estimate for reconstructing an arbitrary pricing system. The range is finite, results are deterministic, the list price is known and every integer is callable. Taxes, rounding, eligibility, history or more input dimensions can make inference much harder. Conversely, if a product displays only a final quote, that quote itself remains a result that can be recorded.

Exhaustive coverage establishes the outputs in the specified domain, not how the function is implemented: different code can produce the same table. An assessment should distinguish predicting results, knowing boundaries and obtaining the original algorithm. For a business, the first two can already matter to pricing strategy.

What the offline boundary changes

When disconnected, a client cannot ask a server for its latest decision. Continuing to calculate is a product capability, and it requires the logic and data needed for that calculation locally. Code transformations, integrity checks and anti-debugging can increase the cost of analysis or modification, but they do not make a result that the user must see disappear. OWASP describes these as defense-in-depth measures and says the other security controls still need to be met according to the threat model. [1]

Write down the objective before selecting controls. Hiding a static string, preventing alteration of licence state and reducing bulk copying of results require different evidence. Give each control a reproducible test, a device scope, a performance budget and a false-positive response. A file scan that finds no plaintext establishes only that this scan did not find it; it does not replace checking normal inputs and outputs and the release build.

Offline operation also changes revocation: a disconnected device cannot immediately receive new revocation information. A licence can expire and require renewal within a grace period, but that changes the experience for users who stay offline for a long time. Define how clock anomalies, lost or replaced devices and service outages are handled, then accept those behaviors against real scenarios.

Separate keys from licensing decisions

Signed licences are one design to consider: the issuer retains a private key and the client carries a public key to verify the licence and signature. Node’s cryptography documentation shows private-key signing and public-key verification. [3] This helps a client check who signed the licence and whether its content changed. It does not automatically conceal licence contents or local rules, and a signature alone cannot provide immediate revocation.

Do not treat a privileged server key shared by all installations as an offline licensing scheme. A device-generated key is a different asset. Android Keystore, for example, can restrict key use and keep key material non-exportable, but its documentation notes that a compromised process might still use the key on the device. [2] Design separate tests for key extraction and misuse of local operations.

Recommendations by requirement
CaseRecommendation
Core function must work offline for long periodsKeep computation local; define observable outputs and acceptable rule disclosure.
Rules must remain under server controlCompute or authorize online; define the no-network experience.
Offline licenceSign at the issuer and verify on the client; define expiry, grace and device replacement.
Device private keyUse the platform keystore with restricted use; test recovery and migration.
Tamper resistance and obfuscationSelect against a threat model; measure effect, compatibility and false positives.

Run a check on your own app

We built a small sample, checked the environment, ran both scans and finally read the actual rules. The probe calls the local function; the rules are read only after both scans finish.

Check the Node.js and macOS versions.
node --version
sw_vers -productVersion

Then choose a bounded set of inputs for a release build you are authorized to test. Hold account, configuration, time and network state constant; record inputs, outputs and call count. For business-critical boundaries, test immediately below, at and above each threshold. If results contain user data, use synthetic data and control access to the records.

Compare the normal and hardened builds with the same inputs, and record whether results agree along with startup time, memory and false positives. Actually disconnect the network and repeat startup, licensing, core calculation, export and reconnection. For differences, retain the version, device and reproduction steps instead of recording only that hardening passed.

Finally, have product and security owners decide together which results must be displayed, which rules may be inferred and which decisions require a connection. Put those constraints in acceptance criteria and repeat the checks when rules or licensing flows change. That makes the offline promise, protection cost and user experience concrete tradeoffs to review.

Your checklist

  • List functions that must work offline and their observable outputs.
  • Probe critical boundaries with synthetic inputs and record call counts.
  • Compare results and performance of normal and hardened release builds.
  • Define offline licence expiry, grace period and device replacement.
  • Move shared privileged keys out of the client and verify the remediation.

Primary sources

All sources and reproduction status ↗