Skip to content

Instantly share code, notes, and snippets.

@yehgdotnet
Last active April 22, 2020 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yehgdotnet/c7de1cd93cda93edd6814b59fd90b088 to your computer and use it in GitHub Desktop.
Save yehgdotnet/c7de1cd93cda93edd6814b59fd90b088 to your computer and use it in GitHub Desktop.
Hide backgrounding in iOS
While analyzing the source code, look for the fields or screens where sensitive data is involved. Identify if the application sanitize the screen before being backgrounded by using UIImageView.
Possible remediation method that will set a default screenshot:
@property (UIImageView *)backgroundImage;
- (void)applicationDidEnterBackground:(UIApplication *)application {
UIImageView *myBanner = [[UIImageView alloc] initWithImage:@"overlayImage.png"];
self.backgroundImage = myBanner;
[self.window addSubview:myBanner];
}
This will cause the background image to be set to the "overlayImage.png" instead whenever the application is being backgrounded. It will prevent sensitive data leaks as the "overlayImage.png" will always override the current view.
----------
There are several proposed methods that may be used to resolve this issue (starting with the recommended method):
1. Use a default screenshot with no sensitive information that will be used instead of the actual data:
@property (UIImageView *)backgroundImage;
(void)applicationDidEnterBackground:(UIApplication *)application { UIImageView *myBanner = [[UIImageView alloc] initWithImage:@"overlayImage.png"]; self.backgroundImage = myBanner; [self.window addSubview:myBanner]; }
2. Mark sensitive fields as hidden in the delegate:
(void)applicationDidEnterBackground:(UIApplication *)application {
viewController.accountNumber.hidden = YES;
viewController.username.hidden = YES;
viewController.SSN.hidden = YES;
viewController.password.hidden = YES;
3. Set the “Application does not run in background” property in the application’s Info.plist file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment