Licence checks: protections and limitations
A local licence check can be modified by someone who controls the computer. Server checks and signed responses address some attacks, but the client still needs to enforce the result.
Local licence checks
A basic check stops the program when the licence is invalid:
if (!license_is_valid()) {
show_nag();
exit(1);
}Compiled, that is a call, a test, and a branch:
call license_is_valid
test al, al
je .invalid ; jump if the check returned falseSomeone modifying this example can change the branch without understanding license_is_valid. Replacing je with jne reverses the test. Replacing it with two nop bytes skips the branch. Setting al to 1 before the test also bypasses the returned result.
A more complex checking function still has this limitation if the program relies on one boolean result.
Obfuscation
Obfuscation makes checks harder to locate. Techniques include repeated checks, encrypted strings, virtualised code and periodic validation.
These techniques increase the work needed to modify the program. They do not prevent a determined person from tracing a refusal message, log entry or exit back to the responsible code. Repeated checks can also be found by recognising the same pattern.
Server-side checks
A server can check licence records without exposing those records or the decision logic to the client.
The client still decides what to do with the response. Someone modifying it may bypass that decision or redirect requests to a server or proxy they control. An unsigned response gives the client no application-level proof of who produced it.
The client therefore needs to authenticate the server's response before relying on it.
Signed responses
The server signs each response with its private key. The client checks the signature against a public key included in the application. A proxy cannot create a valid signature without the private key.
The client needs a trusted key and a way to reject replayed responses.
Include the trusted public key in the app. If the client downloads its trust key at runtime, an attacker who can replace both responses can supply a different key and sign forged responses with it.
Bind each response to its request. The client sends a fresh random nonce with each request. The server includes it in the signed response, and the client checks that it matches. A response recorded from an earlier request will have the wrong nonce and must be rejected.
Together, these checks prevent forged and replayed responses from being accepted by an unmodified client. They do not prevent someone from modifying the verification code itself.
The limit of client-side enforcement
All these approaches still rely on a decision inside the client. You can make the relevant code harder to find or change, but someone who controls the machine may be able to modify the program or its running process.
Delivering required data through the session
Another approach is to keep data the application needs on the server and deliver it only through a valid licence session.
This could be configuration, lookup tables or coefficients used by the application. The data must be necessary for the app to work. Licentry encrypts it with AES-256-GCM using a key derived from the session's access token and device hash. It is encrypted again when a refresh rotates the token.
Skipping the licence check no longer supplies everything the program needs. The modified app still lacks that data. Obtaining it through the server requires a valid session and licence.
A licensed user can still capture the decrypted data and include it in a modified build. This adds extraction and redistribution work to a bypass; it does not make one impossible. Updates that require different data may also require a new bypass. The amount of data and how often it changes affect the work involved.
What these controls can achieve
These controls can increase the work needed to bypass licensing and help you investigate misuse.
Requiring a purchase and extraction of app data adds cost compared with modifying a local check.
Delaying a working bypass may protect some sales during the initial release period.
Periodic server checks let you revoke access during a session. A client that enforces the heartbeat result stops accepting a revoked licence without waiting for the next launch.
Device and IP history can help you investigate shared licences. Per-customer build watermarks may identify the account that downloaded a leaked copy, provided the mark remains intact.
Integration requirements
Pin the response-signing key. Verify responses against the trusted key included in your app. Do not tie that trust to a TLS certificate that changes when the certificate is renewed. Pinning still relies on the client enforcing the check.
Do not rely on a secret protocol. Licentry documents its protocol publicly. Protection depends on secret keys and enforced checks, not on keeping the request format hidden.
Handle outages with a verified offline token. Reject an invalid signature. If the server is unreachable, allow offline access only while a valid, signed grace token permits it. A connection failure alone must not grant access.
Summary
Choose controls based on the attacks you need to address. Test the client's refusal paths and offline behaviour, and keep enough records to investigate suspected sharing. No client-side check can guarantee protection on a machine controlled by the person modifying it.
Licentry provides signed sessions, device-bound tokens and Windows build watermarks. Read the protocol documentation and the client tamper-resistance guidance for integration details.