Hardening Godot Exports Against Reverse Engineering
No export protection is "unobfuscatable" or "unobtainable" — Godot ships an open-source engine, and anything that runs on a user's machine can eventually be inspected (memory dumping, debugger attach, decrypting with the key embedded in the binary). This is true for every engine (Unity, Unreal, Godot) and every commercial obfuscator. The actual, achievable goal is:
- Raise the cost/time of extracting usable scripts and assets far above casual effort.
- Protect your original IP (your own scripts, art, data tables) from drive-by copying.
- Detect and respond to tampering (checksum mismatches, debugger presence) rather than assume prevention is absolute.
This skill treats "stop a specific reverse engineer" as a security-economics problem (cost vs. attacker effort), not a solved cryptography problem. Anyone promising a truly unbreakable client-side protection is selling snake oil — treat such claims (including about specific third-party decompiler/deobfuscator tools) with skepticism.
Minimum viable hardening for a Godot 4.x export, in order of effort vs. payoff:
Bash# 1. Export with script encryption enabled (Project Settings > Editor > Export > Script) # or via export_presets.cfg: script_export_mode=2 # encrypted script_encryption_key="<64-char hex, generated fresh per project>" # Generate a strong key (don't reuse across projects): openssl rand -hex 32
GDSCRIPT# 2. Never trust client-side values for anything that matters server-side. # Encryption only slows script extraction — it does not stop memory inspection # or stop a modified client from lying to your server. # Any authoritative logic (currency, scores, unlocks) must be server-validated.
GDSCRIPT# 3. Add a cheap integrity self-check (raises cost, not a guarantee): func _ready() -> void: if OS.is_debug_build(): return # don't run checks in your own dev builds _verify_pck_checksum() _detect_common_debuggers()
Progress:
- [ ] Step 1: Threat-model — what are you actually protecting, from whom, for how long?
- [ ] Step 2: Separate "must stay secret" from "fine if seen" assets/scripts
- [ ] Step 3: Apply engine-level protections (script encryption, PCK encryption)
- [ ] Step 4: Harden data-at-rest (save files, remote config, level data)
- [ ] Step 5: Add tamper/debugger detection with graceful degradation (not crashes)
- [ ] Step 6: Move anything truly sensitive server-side
- [ ] Step 7: Build a fast automated extraction-attempt test suite
- [ ] Step 8: Re-run suite on every release build before shipping
Step 1: Threat model first
Ask explicitly:
- Who is the attacker? (curious modder vs. a competitor cloning your game vs. a cheat developer)
- What's the actual asset at risk? (gameplay logic, art, a unique algorithm, monetization logic)
- What's the time horizon? (protecting a game's novelty for 3 months pre-launch is very different from "forever")
This determines how much engineering effort is justified. Don't spend two weeks obfuscating a jam game's movement script.
Step 2: Classify assets
| Category | Example | Protection level |
|---|---|---|
| Public by necessity | shaders sent to GPU, client prediction code | Low — accept visibility |
| Competitive-but-not-critical | enemy AI tuning, level scripts | Medium — encryption + checksum |
| High-value IP | proprietary procedural-gen algorithm, anti-cheat logic | High — move server-side if at all possible |
| Authoritative/trust-sensitive | currency, matchmaking rank, purchases | Must be server-side — client protection is irrelevant here |
Step 3: Engine-level protections (Godot specifics)
- Script encryption:
script_encryption_keyin export presets. Rotate per-project; never commit to a public repo; inject via CI secret/environment variable at build time. - PCK encryption: encrypts the whole resource pack, not just scripts — use it when art/data matters too.
- Split build vs. source key: keep the key out of version control entirely; store in CI secrets manager.
- Custom export templates: compiling your own export template with the key baked in (rather than passing it at export time) removes the key from
export_presets.cfg, requiring an attacker to extract it from the compiled template binary instead.
Step 4: Harden data at rest
GDSCRIPT# Save files / local data: encrypt with a key derived from something # not trivially visible in a string dump (not a bare literal). var file := FileAccess.open_encrypted_with_pass(path, FileAccess.WRITE, _derive_key()) func _derive_key() -> String: # Combine multiple non-obvious sources rather than one static string. # Still not unbreakable — just not "grep for the password". return (ProjectSettings.get_setting("application/config/name") as String) \ + str(Time.get_unix_time_from_system() / 1e18) # illustrative, tune per project
Remote config / level data pulled at runtime should be versioned and checksummed server-side so a tampered local copy is rejected rather than silently trusted.
Step 5: Tamper/debugger detection (deterrent, not wall)
GDSCRIPTfunc _detect_common_debuggers() -> bool: # Illustrative pattern: check for known RE tool processes, unexpected # parent process, or timing anomalies around supposedly-fast code paths. # Always fail OPEN in edge cases — false positives that brick legitimate # players are worse than an undetected cracker. return false func _on_tamper_detected() -> void: # Prefer subtle degradation (e.g., disable online features, log telemetry) # over hard crashes — crashes are a trivial breakpoint for an RE session, # subtle failures cost the attacker more debugging time. pass
Step 6: Server-side authority
If something is worth truly protecting (economy values, competitive rankings, unlock state), the fix is architectural, not cryptographic: don't ship the logic to the client at all. No obfuscation substitutes for this.
Step 7: Fast automated extraction test suite
Goal: a suite that runs in minutes, not hours, simulating the first several steps a reverse engineer would actually take, so regressions are caught every build.
Bash#!/usr/bin/env bash # test_extraction_resistance.sh — run against every release candidate export. set -euo pipefail EXPORT_PCK="build/game.pck" EXPORT_BIN="build/game.exe" echo "[1/5] Checking script_encryption_key is not the committed default..." grep -q "script_encryption_key=\"0000" export_presets.cfg && { echo "FAIL: default key in use"; exit 1; } || echo "OK" echo "[2/5] Confirming key is absent from exported binary strings..." strings "$EXPORT_BIN" | grep -F "$(cat ci_secrets/expected_key_fragment.txt)" && { echo "FAIL: key fragment leaked into binary"; exit 1; } || echo "OK" echo "[3/5] Attempting naive PCK unpack with stock godotpcktool..." godotpcktool --unpack "$EXPORT_PCK" --output /tmp/unpack_test 2>/tmp/unpack.log || true test -s /tmp/unpack_test/*.gd 2>/dev/null && { echo "FAIL: plaintext scripts extracted"; exit 1; } || echo "OK: no plaintext .gd recovered" echo "[4/5] Checking save file is not plaintext JSON/text..." file saves/test_save.dat | grep -qi "ASCII text" && { echo "FAIL: save file is plaintext"; exit 1; } || echo "OK" echo "[5/5] Confirming debug symbols stripped from release binary..." file "$EXPORT_BIN" | grep -qi "not stripped" && { echo "WARN: symbols present, consider stripping"; } || echo "OK" echo "All fast checks passed in $SECONDS s."
Keep this suite under ~2 minutes by only running cheap, deterministic checks (static string search, stock unpack-tool attempts, file-type checks) — not full manual RE sessions. Run deeper, slower manual red-team passes only occasionally (e.g., pre-major-release), not on every CI build.
Step 8: Gate releases on the suite
Wire the script into CI so a release build that fails any check doesn't ship.
Example 1:
Input: "I want nobody to ever see my GDScript source."
Output: Not achievable as an absolute. Recommended: enable script encryption with a per-project rotated key built into a custom export template (not left in export_presets.cfg), strip symbols, run the fast extraction-test suite each build, and accept that a sufficiently motivated attacker with a debugger can still read memory at runtime — budget protection effort accordingly rather than promising zero exposure.
Example 2: Input: "My multiplayer game's currency values get modified by cheaters." Output: This isn't an obfuscation problem — it's a trust-boundary problem. Move currency/score calculation and storage to the server, validate all client-submitted actions server-side, and treat the client purely as a renderer of server-confirmed state. No amount of client obfuscation fixes an authority placed in the wrong location.
Example 3: Input: "Someone decompiled my exported game and reused my level-generation script in their own game." Output: Apply script encryption + rotated key for future releases (closes this specific hole going forward), but also note: copying code you don't have rights to is a licensing/legal issue, not only a technical one. Consider a clear LICENSE file and pursuing takedown/DMCA where applicable — technical protection and legal protection are complementary, not substitutes.
- Rotate
script_encryption_keyper project; never commit it; inject at build time from CI secrets. - Keep authoritative game state (currency, rank, unlocks, anti-cheat verdicts) server-side — no client protection substitutes for this.
- Prefer subtle failure over hard crashes when tamper is detected — crashes make an attacker's breakpoint trivial to find.
- Automate the fast extraction-test suite into CI; gate releases on it.
- Re-evaluate threat model per project — don't over-engineer protection for low-stakes projects.
- Combine technical protection with legal protection (licensing, ToS, DMCA) — they solve different parts of the problem.
- Claiming or relying on "unbreakable"/"unobfuscatable" protection — this is not how client-side security works for any engine; design around cost-raising and detection instead.
- Leaving the encryption key in
export_presets.cfgcommitted to a public repo — this is the single most common real-world leak. - Putting authoritative logic client-side and expecting obfuscation to protect it — architecture