DEV Community

Cover image for Software Protection for Developers: What Each Layer Costs
Devirt
Devirt

Posted on

Software Protection for Developers: What Each Layer Costs

Software protection layers cost speed and size: in our tests UPX packing added up to 18 ms per launch and JavaScript obfuscation up to 166× the CPU time. Software protection is the set of layers developers add to a program (licensing, obfuscation, packing, virtualization, anti-tamper) to control its use, and on 23 November 2026 we measured two of them on code we wrote: UPX cut a 3.7 MiB build to 18.8% of its size while adding those 18 ms to every launch, and javascript-obfuscator's string array and control flow flattening made the same JavaScript work take 14.1× and 6.2× the CPU time. Below: what each layer is for, what it costs, what it realistically resists, and how to pick a mix for your own software.

Protect the copy you ship, archive the copy you built: keep the unprotected build, its symbol files and your protector settings next to the source, because protection is applied to the release, not to your repository. If a protected binary you own ever outlives its source, Devirt recovers its logic, including functions a protector virtualized, as annotated pseudocode and an IDA database rather than the original source files, and a free assessment for software owners says what is likely recoverable before any paid work.

What is software protection?

Software protection is the set of technical measures (license checks and code protection) a developer adds to their own program to control who can run it and to slow down anyone who wants to read, copy or change it. It sits next to the legal side (licence terms, copyright) and does a different job: the licence says what users may do, and the protection layers make the forbidden things harder.

Two things it is not. It isn't antivirus, which protects your machine from other people's code. And it isn't the "Software Protection" service you may see in Windows Task Manager (sppsvc), which is Microsoft's licensing and activation service for Windows itself.

Thales, which sells the Sentinel licensing system, says in its protection best practices that no software protection is absolutely uncrackable, and the reason is simple: your program runs on hardware the attacker controls. Protection buys time and raises the skill an attacker needs. The question for a developer is how much time, for which parts of the code, at what cost to users.

What are the layers of software protection?

The layers of software protection are licensing, obfuscation, code virtualization, packing and anti-tamper checks, and each one works at a different point between your source code and the user's machine.

  • Licensing decides who may run the program, which is what software license protection and copy protection mean in practice: license keys, online activation, trials, subscriptions, floating licences, hardware dongles. Signed license files (public-key signatures) stop users from editing their own licence.
  • Obfuscation rewrites the code so it does the same thing but is harder to read: renamed identifiers, encoded strings, flattened control flow, injected dead code. It works on source, bytecode or compiler output.
  • Code virtualization converts chosen functions into bytecode for a small virtual machine (an interpreter) that the protector embeds in your program. A disassembler then shows the interpreter, not your logic.
  • Packing compresses or encrypts the whole executable and adds a stub that restores it in memory at launch. The file on disk no longer looks like your code.
  • Anti-tamper adds checks that notice changes: checksums over code, integrity checks at runtime, debugger detection. When a check fails, the program refuses to run or degrades.

Diagram: where each software protection layer acts between source code and the user's machine. Obfuscation spans source and compiler, virtualization spans compiler and binary, packing and anti-tamper span the binary and the user's machine, and licensing spans the user's machine and your server.

Commercial protectors usually bundle several of these. Protectors with an SDK let you mark which functions get the expensive treatment directly in your source, and we looked at how that works in practice in the VMProtect SDK and its markers.

What does software protection cost? We measured two layers

Software protection costs file size, start-up time, memory and runtime speed, and the mix depends on the layer. None of the four vendor pages we read for "software protection" puts a number on it, so we built two small test programs and measured.

  • Packing: a 73 KiB command-line tool we wrote in C (it fills a 32 MiB buffer, computes a CRC-32 and sorts a million integers), plus a synthetic 3.7 MiB build made of 12,000 generated functions, there only to be big. Both were compiled for Windows x64 and packed with UPX, the open-source executable packer, at three settings.
  • Obfuscation: a JavaScript program we wrote (CRC-32, a numeric sort, a pricing pass over 120,000 generated orders), obfuscated with the open-source javascript-obfuscator, one transform at a time.

Every packed and obfuscated copy produced exactly the same output as the original. The method, sample sizes and caveats are in "How we measured" at the end.

Packing: what UPX did to size, start-up and memory

Packing with UPX halved the small tool, from 74,752 to 37,888 bytes, and cut the larger build from 3.73 MiB to 716 KiB (18.8%) with default settings, or 379 KiB (9.9%) with LZMA. The cost moved to launch time:

Build File size Start-up, median Peak private memory at start
Small tool, unpacked 73.0 KiB 29.2 ms 0.7 MB
Small tool, UPX default 37.0 KiB (50.7%) 29.4 ms 0.8 MB
Small tool, UPX --lzma 36.5 KiB (50.0%) 35.8 ms 0.8 MB
Larger build, unpacked 3.73 MiB 28.9 ms 0.7 MB
Larger build, UPX default 716 KiB (18.8%) 47.3 ms 4.4 MB
Larger build, UPX --lzma 379 KiB (9.9%) 69.7 ms 4.4 MB

Bar charts: UPX packing cost measured on 23 November 2026. The 73 KiB tool shrank to 37 KiB with almost no start-up change; the 3.73 MiB synthetic build shrank to 0.70 MiB but start-up rose from 28.9 to 47.3 ms and private memory from 0.7 to 4.4 MB.

The start-up cost grows with the code you pack. On the 73 KiB tool, default UPX added 1.7 million CPU cycles to a launch (0.3 ms of wall time, inside the noise). On the 3.7 MiB build it added 54 million cycles and 18 ms. LZMA, which UPX's own documentation describes as significantly slower to decompress, more than doubled that.

Packed code doesn't share memory either. Peak private memory at start rose from 0.7 MB to 4.4 MB on the larger build, because the restored code lives in private memory instead of being mapped from the file. UPX's documentation says the same: compressed executables don't share RAM the way file-mapped ones do, so ten copies of a packed tool cost ten copies of its code. Its README also says packed programs run with no runtime or memory penalty for most supported formats; on our Windows x64 builds, private memory at start still rose, so measure it on your own platform.

After launch, speed didn't change. The small tool's full workload took 659 million CPU cycles unpacked and 656 million with default UPX, a difference inside run-to-run noise. The cost sits at start-up, not in your loops.

Animation: a packed program restores itself in memory before your code runs. The unpacked build finishes in 28.9 ms; the UPX-packed build spends extra time restoring code and finishes in 47.3 ms, using 4.4 MB of private memory instead of 0.7 MB.

What packing resists is shallow: casual browsing of strings and code in the file, and size-based tooling. It doesn't stop analysis. UPX says it plainly in its README: the project will not add any sort of protection or encryption, and its documentation describes a built-in switch that restores the original file. Packers that do encrypt still have to restore the code in memory before it runs. Treat packing as a size and first-glance layer, and expect some antivirus engines to look harder at packed files, since packing is common in malware too.

Obfuscation: what each javascript-obfuscator transform cost

Obfuscation cost ranged from nothing to 166× the CPU time in our JavaScript test, depending on which transform was switched on. Each transform below was switched on by itself, on top of identifier renaming and compaction, across the whole program, hot loops included, which is the worst case:

Transform File size CPU time per run
Original 3,065 bytes 172 ms
Identifier renaming 3,016 bytes (0.98×) 172 ms (1.00×)
String array (base64) 5,967 bytes (1.95×) 2,430 ms (14.1×)
Dead code injection (0.4; also turns on an unencoded string array) 5,051 bytes (1.65×) 196 ms (1.14×)
Self-defending (anti-tamper) 3,467 bytes (1.13×) 172 ms (1.00×)
Control flow flattening 7,549 bytes (2.46×) 1,071 ms (6.2×)
"high-obfuscation" preset (debug protection off) 78,899 bytes (25.7×) 28,625 ms (166×)

Bar charts: obfuscation cost per javascript-obfuscator transform, measured on 23 November 2026. Renaming and self-defending cost no CPU time; the string array cost 14.1× and control flow flattening 6.2×; the high-obfuscation preset made the file 25.7× larger and the run 166× slower.

Renaming identifiers and the self-defending transform cost nothing measurable in CPU time, and renaming made the file 2% smaller. Dead code injection grew the file by 65% and cost 14% more CPU. The expensive transforms were the ones that touch hot paths: control flow flattening at 6.2× and, the one we didn't expect, the base64 string array at 14.1×. javascript-obfuscator moves property names such as length into its string table too, so the loop bound of our CRC-32 over an 8 MiB buffer became a call to the string decoder on every one of its 8.4 million passes. Dead code injection switches on the same kind of string table, without encoding, and cost only 1.14×, which suggests the encoded lookup, not the table itself, carries most of that cost. The "high-obfuscation" preset stacks these transforms with others and made the file 25.7× larger and the run 166× slower: 28.6 seconds of CPU for work the original did in 0.17 seconds.

The javascript-obfuscator README warns that control flow flattening can make code up to 1.5x slower, and that obfuscated code in general runs 15 to 80% slower depending on options. Our 6.2× is far past that, most likely because we flattened everything, including the tight loops of a CRC-32. So the cost of obfuscation depends mostly on where you point it. Flattening one license check is cheap, while flattening a hot loop multiplies its cost. If you want the mechanics of what flattening does to a function's structure, our explainer on control flow flattening and opaque predicates walks through it.

What obfuscation resists: reading. Renamed identifiers and encoded strings stop someone from skimming your logic, and flattening makes each function slower to follow by hand. Determined analysts reach for a JavaScript deobfuscator and tracing, so obfuscation adds analysis time rather than ending it.

Virtualization and licensing: what we didn't measure

We didn't measure code virtualization or a commercial licensing system ourselves, so for virtualization we'll quote a published study instead of guessing.

Code virtualization is the most expensive layer per protected function, because an interpreter does work the CPU used to do directly. In the VirtSC study (Ahmadvand et al., Software Protection Workshop 2019), virtualizing 10% of a program's functions added 89% to its runtime on average across its benchmark programs, and virtualizing all of them added 1,018% (the paper's secure mode). The authors call that acceptable only when protection covers a subset of sensitive code, such as license checking. Measure it on your own build before you ship, the same way we measured packing above.

Licensing costs show up somewhere else: an activation server you run, offline and clock-change edge cases, support tickets from paying users who changed their hardware. Those are product costs more than CPU costs, and they're often bigger.

What does each layer realistically resist?

Each layer of software protection resists a different attacker, and none resists all of them. The table maps layer to threat, using our measurements where we have them.

Layer Resists Doesn't stop Cost we measured
Licensing casual copying and sharing, over-use of seats patching the check out of the client, if the check runs only in the client not measured
Obfuscation reading and skimming the code tracing, deobfuscation tools, patient analysts 1.00× to 166× CPU time, by transform
Code virtualization static disassembly of the chosen functions analysis of the interpreter, given time not measured (VirtSC study: +89% runtime with 10% of functions virtualized)
Packing first-glance inspection of the file anything after the code is restored in memory +0.3 ms to +18 ms per launch, private memory
Anti-tamper casual patching of the shipped file an attacker who finds and disables the checks JS self-defending: 1.00× CPU, 1.13× size
Server-side logic everything in the client, because the code never ships outages and latency network round trips

The last row isn't a protection layer in the usual sense, but it's the strongest one in the table: code that runs only on your server can't be read or patched from the client.

Packing vs obfuscation vs virtualization: what's the difference?

Packing, obfuscation and virtualization differ in what they change. Packing compresses or encrypts the whole file and restores it in memory at launch, so its cost lands at start-up and in memory. Obfuscation rewrites the code itself so it stays hard to read while it runs, so its cost lands in the code it touches. Code virtualization turns chosen functions into bytecode for an embedded interpreter, which costs the most per function and is applied selectively.

They also fail differently. A packed program's code exists in plain form in memory once it runs. Obfuscated code stays obfuscated in memory but can be simplified by tools. Virtualized code never exists as native code at all, which is why recovering it is a separate job called devirtualization, and the difference between unpacking and devirtualization matters when you choose which layer guards your most valuable code.

How to choose a software protection mix for your own software

A good software protection mix starts from what you're protecting and from whom, not from a feature list.

  1. Name the asset and the attacker. Revenue from licences, an algorithm, game integrity and API keys each call for different layers. A key that ships inside the client is exposed no matter what wraps it.
  2. Move what matters to the server. Entitlement decisions, pricing logic and secrets that can live server-side should. It's the only layer the client can't touch.
  3. Protect narrowly. Virtualize and flatten the few functions that matter (license validation, key derivation) and leave hot paths alone. Our flattening result shows what happens otherwise.
  4. Measure on your own build. Start-up time, peak memory and the CPU time of your real workload, before and after, with every layer you add.
  5. Test the release, not the debug build. Check crash reporting and symbolication still work, and scan the protected build with a few antivirus engines before shipping; packed and heavily obfuscated files draw more false positives.
  6. Archive the unprotected build. Keep it with its symbol files and the exact protector settings, so you can debug customer crashes and rebuild if the protector or its licence goes away.

Can software protection be bypassed?

Software protection can be bypassed given enough time and skill, because the protected program has to run, in readable form at some level, on a machine the attacker controls. So size it: put the strongest layers on the code whose exposure would cost you most, keep the expensive layers off hot paths, and keep anything that must stay secret off the client.

How we measured

  • Date and machine: 23 November 2026, one Windows 11 Pro PC (AMD Ryzen 7 5700X3D, 16 GB RAM). The machine was running other work, so we report CPU cycles and process CPU time as the main metrics; wall-clock times are medians and include normal Windows process-creation time.
  • Programs: all written for this test. The C tool and the synthetic build were compiled with zig cc (a clang-based compiler) for x86-64 Windows, stripped. The synthetic build is generated code that compresses unusually well; UPX's own README says typical programs shrink by 50 to 70%, not 81%.
  • Packing runs: UPX's official Windows release from its GitHub release page (checksum verified), at default, --best and --lzma. A small C launcher we wrote launched each build with CreateProcess and recorded wall time, CPU cycles (QueryProcessCycleTime) and peak memory. 300 launches per build for start-up (10 interleaved rounds of 30, after a discarded warm-up round) and 60 (small tool) or 40 (larger build) full runs for the workload.
  • Obfuscation runs: javascript-obfuscator, the open-source project's Node.js package, with a fixed seed, one transform switched on per variant on top of renaming and compaction, and debug protection off in the preset; Node.js 22. 42 timed runs per variant across 6 fresh processes, after two warm-up runs per process, with process CPU time from process.cpuUsage().
  • Checks: every packed and obfuscated copy produced byte-identical output to the original.
  • Limits: one program per test on one machine, and no commercial protector, virtualization or licensing system. The javascript-obfuscator release we measured is the one our own site build pins, not the newest major version, so results can differ on newer releases. Treat the numbers as the shape of each layer's cost, then measure your own build.

Top comments (0)