Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-8604] Disable NSFileProtectionComplete for crash reports #1415

Merged
merged 1 commit into from Jun 28, 2022

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Jun 24, 2022

Goal

Fix reporting of crashes that occur while data protection is enabled and the device is locked.

Crash reports were failing to be written, with diagnostic logs like the following:

[Bugsnag] [ERROR] Could not open file [...]/v1/KSCrashReports/swift-ios-CrashState.json for writing: Operation not permitted
INFO : BSG_KSCrashReport.c:1438: bsg_kscrashreport_writeStandardReport(): Writing crash report to [...]/v1/KSCrashReports/CrashReport-E1EEDC19-B397-48B5-A5E7-E45C9E980CD7.json
ERROR: BSG_KSCrashReport.c:1353: bsg_kscrw_i_openCrashReportFile(): Could not open crash report file [...]/v1/KSCrashReports/CrashReport-E1EEDC19-B397-48B5-A5E7-E45C9E980CD7.json: Operation not permitted
ERROR: BSG_KSCrashReport.c:258: bsg_kscrw_i_addJSONElementFromFile(): Could not open file [...]/v1/config.json: Operation not permitted

Changeset

If the default protection is NSFileProtectionComplete, changes the protection for the crash reports directory (and contents) and run_context to NSFileProtectionCompleteUnlessOpen.

NSFileProtectionCompleteUnlessOpen allows new files to be created while the device is locked, but once closed, cannot be opened again until the device is unlocked. This allows crash reports to be written while preserving security through data protection.

Stores config JSON in memory to allow inclusion in crash reports without reading from a file which may be inaccessible.

Testing

Manually verified crash reporting using test app.

@nickdowell nickdowell requested a review from kattrali June 24, 2022 13:29
@github-actions
Copy link

github-actions bot commented Jun 24, 2022

1 Warning
⚠️ This PR modifies BSGRunContext.h but does not change BSGRUNCONTEXT_VERSION

Bugsnag.framework binary size increased by 256 bytes from 815,216 to 815,472

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%    +224  +0.1%    +224    __TEXT,__text
  +0.1%    +120  +0.1%    +120    String Table
  +0.1%     +96  +0.1%     +96    Symbol Table
  +1.4%     +40  +1.4%     +40    Binding Info
  +0.1%     +19  +0.1%     +19    __TEXT,__objc_methname
  +2.3%      +8  +2.3%      +8    __DATA,__got
  +0.1%      +8  +0.1%      +8    __DATA,__objc_selrefs
  +0.2%      +4  +0.2%      +4    Indirect Symbol Table
  +0.1%      +4  +0.1%      +4    __TEXT,__unwind_info
  -0.1%     -13  -0.1%     -13    __TEXT,__cstring
  -0.2%     -16  -0.1%     -16    [__DATA]
  -1.0%    -234  -1.0%    -234    [__TEXT]
  [DEL]      -4  -6.5%    -260    [__LINKEDIT]
  +0.0%    +256  [ = ]       0    TOTAL

Generated by 🚫 Danger

@nickdowell nickdowell force-pushed the nickdowell/disable-file-protection branch from d5aaa07 to d0009da Compare June 27, 2022 12:10
@nickdowell nickdowell changed the title [PLAT-8604] Disable protection on all Bugsnag files [PLAT-8604] Disable protection on crash reports Jun 27, 2022
@nickdowell nickdowell changed the title [PLAT-8604] Disable protection on crash reports [PLAT-8604] Disable protection for crash reports Jun 27, 2022
@nickdowell nickdowell force-pushed the nickdowell/disable-file-protection branch 2 times, most recently from f2091bc to f1792f9 Compare June 27, 2022 13:37
@nickdowell nickdowell changed the title [PLAT-8604] Disable protection for crash reports [PLAT-8604] Disable NSFileProtectionComplete for crash reports Jun 27, 2022
@nickdowell nickdowell changed the title [PLAT-8604] Disable NSFileProtectionComplete for crash reports [PLAT-8604] Disable NSFileProtectionComplete for crash reports Jun 27, 2022
@nickdowell nickdowell force-pushed the nickdowell/disable-file-protection branch 2 times, most recently from 714d1c6 to e177f46 Compare June 27, 2022 14:24
@nickdowell nickdowell force-pushed the nickdowell/disable-file-protection branch from e177f46 to 3c1b96a Compare June 27, 2022 14:48
@nickdowell nickdowell marked this pull request as ready for review June 27, 2022 14:56
@nickdowell nickdowell merged commit e1343de into next Jun 28, 2022
@nickdowell nickdowell deleted the nickdowell/disable-file-protection branch June 28, 2022 07:45
@nickdowell nickdowell mentioned this pull request Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants