Documentation

Go to Portal Website

Strip Bitcode

PlanPlatformsMASVS
TeamiOSMASVS-RESILIENCE-3

Overview

Strip Bitcode removes embedded LLVM bitcode segments from compiled iOS binaries during the application build process. Bitcode is an intermediate representation (LLVM IR) that Apple used to enable App Store-side re-optimization of binaries for different device architectures. However, bitcode segments are trivially decompilable to near-source-quality code, dramatically increase binary size (often 2-4x), and serve no purpose for side-loaded or enterprise-distributed applications.

This control automatically scans all Mach-O binaries in the application bundle (main executable, frameworks, extensions) and removes the __LLVM segment using binary parsing and modification techniques. The result is a smaller, more secure binary that cannot be easily reverse-engineered through its bitcode representation.

Note: Apple deprecated bitcode in Xcode 14 (released September 2022) and no longer accepts bitcode submissions to the App Store. This control primarily serves as a defensive measure for applications built with legacy Xcode versions or that bundle third-party frameworks compiled with older toolchains.

How It Works

The control operates during the iOS application build pipeline after compilation and code signing, but before final packaging:

  1. Binary Discovery: The build system scans the extracted .app bundle to locate all Mach-O binaries:
  1. Bitcode Detection: Each binary is parsed as a Mach-O file (handling both thin and universal/fat binaries). The parser inspects load commands to identify the __LLVM segment, which contains:
  1. Segment Removal: When bitcode is detected:
  1. Binary Rewriting: The modified binary is written back to disk, replacing the original file. The tool preserves:
  1. Size Optimization: Stripping bitcode typically reduces binary size by 50-75%, as the LLVM IR representation is verbose and includes metadata not present in the final machine code.

The control uses the LIEF (Library to Instrument Executable Formats) library for safe, cross-platform Mach-O binary manipulation.

Threats Mitigated

Use Cases

Caveats

Apple Deprecated Bitcode (Xcode 14+)

As of Xcode 14 (September 2022), Apple no longer supports bitcode submission to the App Store. New projects have ENABLE_BITCODE set to NO by default. This control is primarily relevant for:

For modern projects, this control may be a no-op if binaries contain no __LLVM segment.

Re-Signing Required

Stripping bitcode modifies the binary's load commands and segment structure, which invalidates the code signature. The build pipeline automatically re-signs the application after obfuscation controls are applied, but manual builds must ensure code signing occurs after bitcode stripping.

LIEF Library Dependency

The control requires the LIEF Python library (pip install lief). If LIEF is not installed in the build environment, the control will log an error and skip bitcode stripping. The build process will continue without failure.

Universal Binaries

Fat binaries (containing multiple architecture slices, e.g., arm64 and armv7) are processed correctly. Each slice is independently parsed and stripped. This ensures compatibility with universal frameworks targeting multiple device generations.

Support Matrix

PlatformMinimum VersionStatus
iOS9.0+✅ Supported (for legacy bitcode binaries)

Xcode Version Notes:

How to Enable the Control

Navigate to Code Obfuscation from the AppTego portal, and expand the Metadata Reduction section. Under this section you will find the Strip Bitcode control. Click Enable to apply it to the next protected build.

API Configuration Example

{
  "StripBitcode": {
    "protection": true
  }
}

Default Behavior: If the control is not present in the configuration, bitcode is not stripped (opt-in control).