Skip to content

MASTG-KNOW-0061: Binary Protection Mechanisms

Detecting the presence of binary protection mechanisms heavily depend on the language used for developing the application.

Although Xcode enables all binary security features by default, it may be relevant to verify this for old applications or to check for compiler flag misconfigurations. The following features are applicable:

Learn more:

Tests to detect the presence of these protection mechanisms heavily depend on the language used for developing the application. For example, existing techniques for detecting the presence of stack canaries do not work for pure Swift apps.

Xcode Project Settings

Stack Canary protection

Steps for enabling stack canary protection in an iOS application:

  1. In Xcode, select your target in the "Targets" section, then click the "Build Settings" tab to view the target's settings.
  2. Make sure that the "-fstack-protector-all" option is selected in the "Other C Flags" section.
  3. Make sure that Position Independent Executables (PIE) support is enabled.

PIE protection

Steps for building an iOS application as PIE:

  1. In Xcode, select your target in the "Targets" section, then click the "Build Settings" tab to view the target's settings.
  2. Set the iOS Deployment Target to iOS 4.3 or later.
  3. Make sure that "Generate Position-Dependent Code" (section "Apple Clang - Code Generation") is set to its default value ("NO").
  4. Make sure that "Generate Position-Dependent Executable" (section "Linking") is set to its default value ("NO").

ARC protection

ARC is automatically enabled for Swift apps by the swiftc compiler. However, for Objective-C apps you'll have ensure that it's enabled by following these steps:

  1. In Xcode, select your target in the "Targets" section, then click the "Build Settings" tab to view the target's settings.
  2. Make sure that "Objective-C Automatic Reference Counting" is set to its default value ("YES").

See the Technical Q&A QA1788 Building a Position Independent Executable.