Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.
Documents
directory without properly masking it first.Documents
directory is intended to store non-transient application data, such as user-created content or local information allowing the app to run in offline mode. If UIFileSharingEnabled
is set in your application's Info.plist
file, files here will be accessible via iTunes. When writing sensitive data to the Documents
directory, the data may be exposed in unencrypted backups or through the iTunes interface.Documents
directory:
...
NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *passwd_path = [docsDirectory stringByAppendingPathComponent:@"passwords.txt"];
NSString *password = [user password];
[password writeToFile:passwd_path atomically:YES encoding:NSUTF8StringEncoding error:nil];
...
Documents
directory without properly masking it first.Documents
directory is intended to store non-transient application data, such as user-created content or local information allowing the app to run in offline mode. If UIFileSharingEnabled
is set in your application's Info.plist
file, files here will be accessible via iTunes. When writing sensitive data to the Documents
directory, the data may be exposed in unencrypted backups or through the iTunes interface.Documents
directory:
let documents = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
let passwd_path = NSURL(fileURLWithPath: documents).URLByAppendingPathComponent("secret.txt")
let password = getUserPassword()
try password.writeToURL(passwd_path, atomically:true, encoding: NSUTF8StringEncoding)
DataType
as a password, meaning that by default it will be shown when displayed:
public class User
{
[Required]
public int ID { get; set; }
public string Title { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime DateOfEmployment { get; set; }
[DataType(DataType.Currency)]
public decimal Salary { get; set; }
[Required]
public string Username { get; set; }
[Required]
public string Password { get; set; }
...
}
Password
in Example 1
did not specify the attribute [DataType(DataType.Password)]
, it will not be hidden by default when displayed in the UI.TextField
widget does not obscure a user's password as they type it at the input prompt:
class SelectionContainerDisabledExampleApp extends StatelessWidget {
const SelectionContainerDisabledExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
hintText: "Please enter your password",
),
),
],
),
),
),
);
}
}
TextField
widget in Example 1
was not instantiated with obscureText
property, set to true
, the password is not obscured when the user types it at the "Please enter your password: " prompt.PasswordCallback pc = new PasswordCallback("Please enter your password: ", true);
pc
in Example 1
was instantiated with its second parameter, onEcho
, set to true
, the password is not obscured when the user types it at the "Please enter your password: " prompt.
ViewController.h:
...
@property (nonatomic, retain) IBOutlet UITextField *passwordField;
...
ViewController.m:
...
NSString *password = _passwordField.text;
...
passwordField
in Example 1
did not have its secureTextEntry
property set to true
, the password is not obscured when the user types it into the text field.
...
@IBOutlet weak var passwordField: UITextField!
...
let password = passwordField.text
...
passwordField
in Example 1
did not have its secureTextEntry
property set to true
, the password is not obscured when the user types it into the text field.
from oslo_config import cfg
...
opts = [
cfg.StrOpt('admin_password',secret=False,
help="User's password")]
...
grp = cfg.OptGroup('mygroup')
cfg.CONF.register_opts(opts, group=grp)
...
logger.warning("Adding %s" % cfg.CONF.mygroup.admin_password)
Example 1
writes admin_password
in plain text (unobfuscated) to the log output, as the value of secret
is set to False
. Although many developers trust the eventlog as a safe storage location for data, it should not be trusted implicitly, particularly when privacy is a concern.<uses-permission .../>
element of AndroidManifest.xml declares usage of the ACTIVITY_RECOGNITION
permission, which enables an application to recognize the user's physical activity.<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the READ_CALENDAR
permission, which enables an application to read the user's calendar data.<uses-permission android:name="android.permission.READ_CALENDAR"/>Example 2: The
<uses-permission .../>
element of AndroidManifest.xml declares usage of the WRITE_CALENDAR
permission, which enables an application to write to the user's calendar data.<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the READ_CALL_LOG
permission, which enables an application to read the user's call log.<uses-permission android:name="android.permission.READ_CALL_LOG"/>Example 2: The
<uses-permission .../>
element of AndroidManifest.xml declares usage of the WRITE_CALL_LOG
permission, which enables an application to write to the user's call log.<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the CAMERA
permission, which enables an application to access the device's camera.<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the READ_CONTACTS
permission, which enables an application to read the user's contacts data.<uses-permission android:name="android.permission.READ_CONTACTS"/>Example 2: The
<uses-permission .../>
element of AndroidManifest.xml declares usage of the WRITE_CONTACTS
permission, which enables an application to write to the user's contacts data.<uses-permission android:name="android.permission.WRITE_CONTACTS"/>Example 3: The
<uses-permission .../>
element of AndroidManifest.xml declares usage of the GET_ACCOUNTS
permission, which enables an application to access the user's email and online accounts stored in the Account Manager. Sensitive data such as account IDs, email addresses, and phone numbers can be accessed with this permission.<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the WRITE_EXTERNAL_STORAGE
permission, which enables an application to write to external storage.<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>Example 2:The
<uses-permission .../>
element of AndroidManifest.xml declares usage of the READ_EXTERNAL_STORAGE
permission, which enables and application to read from external storage.<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.BRICK"/>
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, locationListener);
sms.sendTextMessage(recipient, null, message, PendingIntent.getBroadcast(SmsMessaging.this, 0, new Intent(ACTION_SMS_SENT), 0), null);
<uses-permission .../>
element of AndroidManifest.xml declares usage of the RECORD_AUDIO
permission, which enables an application to record audio using the device's microphone.<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the BLUETOOTH_ADVERTISE
permission, which enables an application to advertise to nearby Bluetooth devices.<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the POST_NOTIFICATIONS
permission, which enables an application to send notifications to the device user.<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the READ_MEDIA_AUDIO
permission, which enables an application to read music and audio files on the device.<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission .../>
element of AndroidManifest.xml declares usage of the READ_MEDIA_VIDEO
permission, which enables an application to read video files on the device.<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>