We cracked our own protected binary
Auth checks can be bypassed with just six modified bytes. Binary obfuscation raises the cost of cracking, but greater security requires keeping secrets off the client.
By System Locker 7 min read
We recently created a test application using Bedrock and ran a simulated attack against it. The target was a small Windows x64 console program that asks for a license key, verifies it with our standard Bedrock .NET library, and prints a hidden secret if authentication succeeds. We compiled it to native machine code with .NET NativeAOT and protected it with Rampart. Then we handed over only the finished executable: no source code, no debug symbols, no valid license key, and no permission to probe System Locker's servers.
Our protection fell apart by changing just six bytes.
Running exercises like this keeps our advice grounded in how reverse engineers work in practice. What happened inside that binary shows what obfuscation can stop and where application architecture has to take over.
Copy this tutorial and its code examples as plain text for an AI assistant or a clarifying question.
What Bedrock and Rampart got right
Bedrock's authentication layer held from start to finish. The attacker never forged a server response, broke an Ed25519 signature, replayed an earlier session, or exploited System Locker's API. When the modified binary submitted a deliberately invalid key, our servers sent back a normal signed denial.
Rampart also stopped the quick attacks that take down unprotected Windows apps. Open any ordinary .NET executable in a decompiler, and readable C# falls right out. Running a strings dump against an unprotected binary yields every error prompt, endpoint, and embedded value. Thanks to Rampart, neither of those routes worked here.
Rampart protected the managed assembly before NativeAOT compiled it and scrubbed headers and section names afterward. There was no managed IL to decompile, no plaintext UI strings waiting in the executable, and no readable copy of the secret sitting in static data. Both the final authentication gate and the routines that decoded the secret were transformed and virtualized before native compilation. Casual cracking tools turned up empty.
The six-byte chokepoint
Static extraction went nowhere, so the analyst switched to watching the program run. That move exposed the weak spot in the test app's design.
First, the analyst ran the untouched binary with proxy environment variables pointed at a closed local port. That revealed the startup prompt and confirmed how the app behaved on a network error without sending traffic to System Locker.
Next came finding the application logic inside a stripped multi-megabyte native executable. Rampart's string encryption stopped a simple cross-reference search for the license prompt, yet the program still had to pass that prompt to Windows in plaintext when printing to the console. By hooking the imported WriteFile slot in the Import Address Table (IAT) and walking the native call stack through Windows' retained x64 unwind metadata (.pdata), the analyst jumped straight into the async Main state machine.
Because authentication had not yet occurred, Bedrock's heartbeat checks weren't active—meaning the analyst could run the program with a debugger attached and slowly step through the license verification without failing the sensitive timing checks. The analyst traced the flow from the license prompt to the Bedrock AuthenticateWithKeyAsync call, then into the virtualized code that decoded the server response.
Disassembling the code right after authentication showed a compact decision point:
call result_classifier
cmp eax, 1
je success_block
Even with a virtualized gate sitting behind that call, the caller collapsed the whole authentication result into one integer comparison and a single conditional branch. Falling through printed the denial message. Taking the jump entered the local success block, which decoded and printed the secret without needing a session token or another answer from System Locker.
Patching the binary on disk took six bytes. On a separate copy of the executable, the analyst replaced the six-byte conditional JE rel32 instruction (0F 84 ...) with a five-byte unconditional JMP rel32 followed by a one-byte NOP (E9 ... 90). When the patched executable ran with a bogus license key, Bedrock returned an ordinary signed denial object, execution hit the patched jump, and the app walked straight into the success path and printed the secret.
Why local gates always hit a ceiling
The flaw sat in the trust boundary of the test application. Every local-only license check follows the same three steps:
- The client asks System Locker whether a license is valid.
- Local code reduces that response to a pass-or-fail branch.
- That branch unlocks a secret or feature already bundled in the binary.
An attacker who owns the machine controls steps 2 and 3. Native compilation, symbol stripping, string encryption, and virtualization make the branch harder to locate and modify, yet none of them can take control of the CPU away from the person running the file. When protected data ships inside the same executable as the check, a determined reverse engineer never needs a valid key. They can edit the jump, override the classifier's return value, or invoke the success routine directly.
Several common hardening ideas run straight into this same wall. Heavier string encryption still produces plaintext right before data crosses an OS boundary like WriteFile or a UI draw call. Corrupting unwind metadata hinders one stack-walk technique while breaking your own crash dumps and leaving static analysis and instruction tracing open. Authenticode signing proves publisher identity and catches tampered downloads in transit, yet Windows does not stop a machine owner from modifying a local copy and running it. Stacking extra local if checks adds a few more patch sites without changing who owns the process.
What we are strengthening in Rampart
Even with that architectural limit in mind, the test surfaced two concrete hardening gaps in Rampart that we are addressing.
First, the patched NativeAOT executable started cleanly after a six-byte change in its code section. Rampart already supports runtime code measurement on standard native PE builds, while its NativeAOT post-link pass currently stays conservative so it does not disturb runtime metadata. We are expanding Rampart's tamper detection to cover executable code pages with integrity checks verified from multiple independent locations, backed by automated tests that mutate branch bytes and confirm the build halts instead of running as normal.
Second, the post-authentication path left a compact call, cmp, and je choke point. We are adding stronger control-flow transforms and check distribution in Rampart so sensitive decisions are harder to isolate into a single six-byte edit and do not hinge on one reusable success flag.
Those upgrades raise reverse-engineering cost without turning a local executable into a trusted server. Any integrity check that runs inside an attacker-controlled process can eventually be patched out too. Rampart's job is to stop casual cracking and make tampering expensive enough that opportunistic attackers move on. Application architecture still has to guard the valuables.
Keep secrets off the client with Invisible Folder
If a local jump can always be flipped, the durable fix is straightforward: keep secrets and vital code out of the distributed binary for as long as possible.
Treat the executable that customers download as an authentication shell and user interface. Keep proprietary data and vital application code off the machine until System Locker has confirmed a valid license on the server. Where each piece belongs depends on what you are protecting:
- Small secrets, webhook endpoints, and live settings belong in Server Side Variables. Bedrock returns protected variables inside its signed response only when authentication succeeds, so they stay out of your compiled binary and can be rotated without shipping a new build.
- Privileged operations and master credentials belong on a backend you control. Database passwords, signing keys, and irreversible actions should never reach a customer PC.
- Larger payloads, proprietary modules, licensed assets, scripts, or secondary binaries belong in Invisible Folder, delivered only after a verified Bedrock session starts.
That tight integration between System Locker and Invisible Folder closes the exact hole our simulated attack exploited. When you protect a file group in Invisible Folder with the System Locker Advanced permission, a leaked license key on its own is not enough to download anything. Your app has to complete a Bedrock authentication request with init-if=true. System Locker verifies the credentials, hardware lock (SL-HWID), program digest, and active Aegis rules on our servers. Only when those checks pass does Bedrock return a short-lived invisible_folder_token inside the signed response, and a heartbeat with init-if=true can refresh it later in the session.
Any request to Invisible Folder without a valid session token gets a plain 404 Not Found, identical to a link that never existed. Replay our six-byte patch against that flow and the outcome flips:
Local-vault pattern:
authenticate -> denial -> patched JMP -> local secret revealed
Server-capability pattern (Bedrock + Invisible Folder):
authenticate -> denial (no token issued) -> patched JMP -> Invisible Folder returns 404
The attacker can still turn JE into JMP inside the distributed binary, and execution will still reach the success block. But this time around, the attacker leaves empty-handed because System Locker never issued a download token, and Invisible Folder will not hand over bytes without a valid token. Patching a local jump cannot invent data that never left the server.
Use the download-to-memory option
How your program handles a protected file after download matters almost as much as gating the download itself. Writing a sensitive module, script bundle, or licensed asset straight to %TEMP% or the install directory leaves a clean, unencrypted file on disk where anyone can copy it or keep it after a license expires.
Our official Bedrock libraries expose an in-memory download path right beside disk downloads. Rather than saving a file to the filesystem, your app pulls the bytes directly into a memory buffer and consumes them in process. The Bedrock download token itself stays in memory only and is cleared when the client shuts down.
In the Bedrock .NET library, ask for the token during initialization and call DownloadAsync (or omit the destination argument on DownloadIfNewAsync when you also want revision checking):
using SystemLocker.Bedrock;
await using var client = new BedrockClient(new BedrockConfig
{
SystemId = "YOUR_SYSTEM_ID",
SigningPublicKey = "YOUR_BASE64URL_ED25519_PUBLIC_KEY",
Version = "1.0.0",
});
var auth = await client.AuthenticateWithKeyAsync(
licenseKey,
new InitializationOptions { RequestInvisibleFolderToken = true });
if (!auth.SessionStarted)
{
return;
}
// Pull protected bytes directly into memory instead of writing them to disk.
byte[] payload = await client.InvisibleFolder.DownloadAsync("YOUR_FILE_REFERENCE_ID");
In the Bedrock C++ library, the same flow calls download() (or downloadIfNew() without a destination path) and returns a std::vector<std::uint8_t> in RAM:
syslocker::bedrock::InitializationOptions options;
options.requestInvisibleFolderToken = true;
auto auth = client.authenticateWithKey(licenseKey, options);
if (!auth || !auth->sessionStarted) {
return 1;
}
// Returns bytes directly in memory; nothing is written to disk.
auto payload = client.invisibleFolder().download("YOUR_FILE_REFERENCE_ID");
if (!payload) {
return 1;
}
For larger desktop tools, this pairs well with a thin launcher. Distribute your updater or shell through our software distribution setup, harden that launcher with Rampart, and pull your sensitive modules, configurations, or licensed data straight into memory through System Locker Advanced once Bedrock validates the session.
One boundary still holds even with in-memory delivery: a customer who possesses a valid, active license can inspect process memory while the program runs. Downloading to memory stops unauthenticated patching cracks and keeps paid payloads off the public installer and off the user's disk. Anything that would cause serious damage if a single paying customer extracted it still belongs on infrastructure you control.
Test your release like an attacker
Before shipping a build, run a quick hostile-client pass against your own release executable. You do not need exotic tooling to catch the same trust-boundary bug we just demonstrated:
- Scan the release binary for embedded secrets, endpoints, or data that should exist only after a valid login.
- Patch your main authentication branch in a local copy so a rejected login takes the success path, then run it with a bogus key.
- Verify that the patched build unlocks no local secret, receives no Server Side Variables, and gets rejected by Invisible Folder.
A modified client can always be forced to display a fake logged-in screen. The test passes when that screen has nothing valuable behind it.
Bedrock handles signed authorization, hardware locking, and rotating sessions. Rampart makes your distributed binary far harder to inspect and patch, and upcoming tamper-detection and branch-hardening updates will push that work factor higher. Keeping sensitive payloads behind Invisible Folder until the server clears the session leaves a six-byte edit with nothing to unlock.
Put your protected payloads behind a live session
Link Invisible Folder to your System Locker account, fetch sensitive modules into memory with Bedrock, and harden your launcher with Rampart. Rampart is 100% free, and works with any C++ or .NET project.