sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Adjust compiler settings to best practices

Open omninode opened this issue 1 year ago • 3 comments

Description

Hello, during the last pen test of our app, the testers noticed that some compiler settings do not comply with best practices.

Debugging symbols: During the compilation process of the app, debugging symbols are not removed. This makes it easier for potential attackers to reverse engineer the app by exposing internal information about the app. To remove debugging symbols, the following 3 options should be set to “Yes” for the release version in the build settings of the Xcode project:

- Strip Debug Symbols During Copy:
	- `COPY_PHASE_STRIP = YES`

- Strip Linked Product:
	- `STRIP_INSTALLED_PRODUCT = YES`

- Deployment Postprocessing: 
	- `DEPLOYMENT_POSTPROCESSING = YES`

Stack Canaries: The stack canaries are deactivated. This facilitates the use of so-called buffer overflows, with which it is possible to change the behavior of the application at runtime. Using the compiler option fstack-protector-all activates the stack canaries.

- Stack canaries 
	- `OTHER_CFLAGS[arch=*] = “-fstack-protector-all”`

Request: Is there something against completing these pen test recommendations in the release configuration of the SDK?

omninode avatar Jul 17 '24 14:07 omninode

Hello @omninode, thanks for reaching out.

This makes it easier for potential attackers to reverse engineer the app

This is not a concern since our SDK is open source, but I do agree we don't need to ship it with debug symbols, in order to save some bytes.

How are you using Sentry (SPM, cocoapods, pre-build framework)?

Stack Canaries

Im not familiar with this, we need to investigate.

brustolin avatar Jul 18 '24 07:07 brustolin

Hi,

on behalf of @omninode, who is on vacation this week: we're using Sentry via SPM.

kind regards, Steffen

darthsteff avatar Jul 24 '24 14:07 darthsteff

We're gonna investigate if stripping debug symbols has a potential to deteriorate ability to symbolicate Sentry stack frames.

We're currently not planning to auto-enable stack canaries for all builds. If you want/need to use it, you currently need to build the SDK yourself with the desired compiler flags and settings.

kahest avatar Jul 31 '24 12:07 kahest

Hello, Any plans for merging this PR in production. I am getting same issue raised by pen testers. P.S using SDK via SPM

aadeshAvoma avatar Nov 05 '25 07:11 aadeshAvoma

No, sorry @aadeshAvoma, we don't have an update for this issue or an ETA yet.

philipphofmann avatar Nov 06 '25 12:11 philipphofmann

@philipphofmann Could you please advise on the recommended approach to mitigate this security concern raised during our penetration testing, other than forking and applying a local fix? It would also be greatly appreciated if this could be acknowledged as an issue, so that it may be considered for prioritization in your task list.

aadeshAvoma avatar Nov 06 '25 13:11 aadeshAvoma

@philipphofmann Could you please advise on the recommended approach to mitigate this security concern raised during our penetration testing, other than forking and applying a local fix? It would also be greatly appreciated if this could be acknowledged as an issue, so that it may be considered for prioritization in your task list.

I wonder why this is flagged as a security concern, all these affect our generated SDK. So yes, it would be easier to reverse engineer the Sentry SDK, but that doesn't affect your app which is using Sentry. (Sentry is open source, so there is no risk for any RE here)

Also, if you have STRIP_INSTALLED_PRODUCT in your application configuration you will strip everything after linking. You can also use https://docs.emergetools.com/docs/strip-binary-symbols to manually strip everything from your dependencies

As for fstack-protector-all, seems interesting, but it creates a larger binary and possibly run slower. Looks like we will need to test it

itaybre avatar Nov 06 '25 14:11 itaybre

Closing this issue since:

  • Settings in the SDK should not affect security within another app.
  • I see that COPY_PHASE_STRIP and STRIP_INSTALLED_PRODUCT are already enabled when building the SDK for release.

Regarding the stack protection flag, I created another issue to follow this up: #6699

itaybre avatar Nov 06 '25 17:11 itaybre