Security and Privacy
Security and Privacy
• If you don’t prioritize security, you and your customers will inevitably
suffer losses from malicious attacks.
• In the worst case, these attacks could can put product providers out of
business.
• Even if they can recover from the attacks, this will take time and effort
that would have been better spent working on their software.
Availability Integrity
threats threats
SOFTWARE PRODUCT
PROGRAM
Example: Virus
Example: Distributed denial
of service attack DATA
Example: Ransomware
Confidentiality
threats
Operational environment
Application
System libraries
Database
Operating system
Software infrastructure
Network
Attack monitoring
The system should be regularly checked for possible unauthorized access. If attacks
are detected, it may be possible to put resistance strategies in place that minimize the
effects of the attack.
Backup
Backup policies should be implemented to ensure that you keep undamaged copies of
program and data files. These can then be restored after an attack.
• Injection attacks are a type of attack where a malicious user uses a valid
input field to input malicious code or database commands.
• SQL poisoning attacks are attacks on software products that use an SQL
database.
• A malicious user uses a form input field to input a fragment of SQL that
allows access to the database.
• The form field is added to the SQL query, which is executed and returns
the information to the attacker.
3.
Malware script
sends session cookie
to attacker
Valid request for data
from website
Browser
2.
Victim Data delivered and malware
script installed in victim’s browser
• A session is a time period during which the user’s authentication is valid. They don’t
have to re-authenticate for each interaction with the system.
• The authentication process involves placing a session cookie on the user’s device
• There are several ways that an attacker can find out the session cookie
value including cross-site scripting attacks and traffic monitoring.
• In a cross-site scripting attack, the installed malware sends session cookies to the
attackers.
• Traffic monitoring involves attackers capturing the traffic between the client and
server. The session cookie can then be identified by analysing the data exchanged.
Traffic encryption
Always encrypt the network traffic between clients and your server. This means
setting up sessions using https rather than http. If traffic is encrypted it is harder
to monitor to find session cookies.
Multi-factor authentication
Always use multi-factor authentication and require confirmation of new actions
that may be damaging. For example, before a new payee request is accepted,
you could ask the user to confirm their identity by inputting a code sent to their
phone. You could also ask for password characters to be input before every
potentially damaging action, such as transferring funds.
Short timeouts
Use relatively short timeouts on sessions. If there has been no activity in a
session for a few minutes, the session should be ended and future requests
directed to an authentication page. This reduces the likelihood that an attacker
can access an account if a legitimate user forgets to log off when they have
finished their transactions.
• Denial of service attacks are attacks on a software system that are intended to make
that system unavailable for normal use.
• Distributed denial of service attacks (DDOS) are the most common type of denial of
service attacks.
• These involve distributed computers, that have usually been hijacked as part of a botnet,
sending hundreds of thousands of requests for service to a web application. There are so
many service requests that legitimate users are denied access.
• User lockout attacks take advantage of a common authentication policy that locks out a user
after a number of failed authentication attempts. Their aim is to lock users out rather than gain
access and so deny the service to these users.
• Users often use their email address as their login name so if an attacker has access to a
database of email addresses, he or she can try to login using these addresses.
• If you don’t lock accounts after failed validation, then attackers can use brute-force
attacks on your system. If you do, you may deny access to legitimate users.
• Brute force attacks are attacks on a web application where the attacker
has some information, such as a valid login name, but does not have the
password for the site.
• The attacker creates different passwords and tries to login with each of
these. If the login fails, they then try again with a different password.
• Attackers may use a string generator that generates every possible combination
of letters and numbers and use these as passwords.
• Brute force attacks rely on users setting weak passwords, so you can
circumvent them by insisting that users set long passwords that are not
in a dictionary or are common words.
• You also use authentication to learn about your users so that you can
personalize their experience of using your product.
Knowledge Password
Possession Mobile
device
• Knowledge-based authentication
• The user provides secret, personal information when they register with the
system. Each time they log on, the system asks them for this information.
• Possession-based authentication
• This relies on the user having a physical device (such as a mobile phone) that
can generate or display information that is known to the authenticating system.
The user inputs this information to confirm that they possess the authenticating
device.
Insecure passwords
Users choose passwords that are easy to remember. However, it is also easy for
attackers to guess or generate these passwords, using either a dictionary or a
brute force attack.
Phishing attacks
Users click on an email link that points to a fake site that tries to collect their login
and password details.
Password reuse
Users use the same password for several sites. If there is a security breach at
one of these sites, attackers then have passwords that they can try on other
sites.
Forgotten passwords
Users regularly forget their passwords so that you need to set up a password
recovery mechanism to allow these to be reset. This can be a vulnerability if
users’ credentials have been stolen and attackers use it to reset their passwords.
• ‘Login with Google’ and ‘Login with Facebook’ are widely used examples
of authentication using federated identity.
• The advantage of federated identity for a user is that they have a single
set of credentials that are stored by a trusted identity service.
• They don’t have to keep track of different user ids and passwords.
Because their credentials are stored in fewer places, the chances of a
security breach where these are revealed is reduced.
Request credentials
Provide credentials
Return authentication
token
Authentication
response
• For example, if you use a shared folder on Dropbox, the folder’s owner may
authorize you to read the contents of that folder, but not to add new files or
overwrite files in the folder.
• When a business wants to define the type of access that users get to
resources, this is based on an access control policy.
• This policy is a set of rules that define what information (data and
programs) is controlled, who has access to that information and the type
of access that is allowed
• Explicit access control policies are important for both legal and technical
reasons.
• Data protection rules limit the access the personal data and this must be
reflected in the defined access control policy. If this policy is incomplete or does
not conform to the data protection rules, then there may be subsequent legal
action in the event of a data breach.
• Technically, an access control policy can be a starting point for setting up the
access control scheme for a system.
• For example, if the access control policy defines the access rights of students,
then when new students are registered, they all get these rights by default.
• Access control lists (ACLs) are used in most file and database systems
to implement access control policies.
• Access control lists are tables that link users with resources and specify
what those users are permitted to do.
• For example, for this book I would like to be able to set up an access control list
to a book file that allows reviewers to read that file and annotate it with
comments. However, they are not allowed to edit the text or to delete the file.
User Permissions
All Read
Staff Create, Edit
Resource Access
Sysadmin Delete
A
B User Permissions
All Execute
C
Sysadmin Create, Delete
D
User Permissions
...
Admin Create, Read, Edit
Teaching staff Read, Edit
Student Read
if student = student_id
if department = dept_id
• Modern encryption techniques are such that you can encrypt data so that
it is practically uncrackable using currently available technology.
Secret Secret
key key
• If Alice and Bob wish to exchange a secret message, both must have a
copy of the encryption key. Alice encrypts the message with this key.
When Bob receives the message, he decodes it using the same key to
read its contents.
• If Alice simply sends the key to Bob, an attacker may intercept the
message and gain access to the key. The attacker can then decode all
future secret communications.
Alice Bob
a7Dr6yYt9F... a7Dr6yYt9F...
encrypt decrypt
• Each user has a public and a private key. Messages may be encrypted
using either key but can only be decrypted using the other key.
• Public keys may be published and shared by the key owner. Anyone can
access and use a published public key.
Alice Bob
dr5ts3TR9dt hTr34BbfsDy
x4ztmRsYY... 9r3g5HHt76...
encrypt decrypt
• Say Alice wants to send a message to Bob and she has a copy of his
public key.
• However, she is not sure whether or not the public key that she has for
Bob is correct and she is concerned that the message may be sent to the
wrong person.
• Bob uses his private key to encrypt a message and sends this to Alice. If it can
be decrypted using Bob’s public key, then Alice has the correct key.
Bob Alice
hTr34BbfsDy dr5ts3TR9dt
9r3g5HHt76... x4ztmRsYY...
encrypt decrypt
I am really I am really
Encrypted text
Bob Bob
• TLS encryption depends on a digital certificate that is sent from the web
server to the client.
• The CA encrypts the information in the certificate using their private key to create a
unique signature. This signature is included in the certificate along with the public
key of the CA. To check that the certificate is valid, you can decrypt the signature
using the CA’s public key.
Subject information
Information about the company or individual whose web site is being visited. Applicants
apply for a digital certificate from a certificate authority who checks that the applicant is a
valid organization.
Certificate information
Information about the certificate itself, including a unique serial number and a validity
period, defined by start and end dates.
Digital signature
The combination of all of the above data uniquely identifies the digital certificate. The
signature data is encrypted with the CA’s private key to confirm that the data is correct. The
algorithm used to generate the digital signature is also specified.
Generate RS is a large
RS random number
End End
session session
Security and Privacy © Ian Sommerville 2018: 35
TLS explained
• The digital certificate that the server sends to the client includes the
server’s public key. The server also generates a long random number,
encrypts it using its private key and sends this to the client.
• The client can then decrypt this using the server’s public key and, in turn,
generates its own long random number. It encrypts this number using the
server’s public key and sends it to the server, which decrypts the
message using its private key. Both client and server then have two long
random numbers.
• As a product provider you inevitably store information about your users and,
for cloud-based products, user data.
• Encryption can be used to reduce the damage that may occur from data
theft. If information is encrypted, it is impossible, or very expensive, for
thieves to access and use the unencrypted data.
• Data in transit.
When transferring the data over the Internet, you should always use the https rather
than the http protocol to ensure encryption.
• Data at rest.
If data is not being used, then the files where the data is stored should be encrypted
so that theft of these files will not lead to disclosure of confidential information.
• Data in use
The data is being actively processed. Encrypting and decrypting the data slows
down the system response time. Implementing a general search mechanism with
encrypted data is impossible,
Application
Calls
Unencrypted data
API
Key management
API Encryption
system engine
Keys
• For example, in the UK, tax and company data has to be maintained for at least
six years, with a longer retention period for some types of data. Data protection
regulations may require that this data be stored securely, so the data should be
encrypted.
• The importance of privacy has changed over time and individuals have
their own views on what degree of privacy is important.
• Culture and age also affect peoples’ views on what privacy means.
• Younger people were early adopters of the first social networks and many of
them seem to be less inhibited about sharing personal information on these
platforms than older people.
• If you are offering a product directly to consumers and you fail to conform
to privacy regulations, then you may be subject to legal action by product
buyers or by a data regulator. If your conformance is weaker than the
protection offered by data protection regulations in some countries, you
won’t be able to sell your product in these countries.
• These laws limit the collection, dissemination and use of personal data to
the purposes for which it was collected.
• For example, a travel insurance company may collect health information so that
they can assess their level of risk. This is legal and permissible.
• However, it would not be legal for those companies to use this information to
target online advertising of health products, unless their users had given specific
permission for this.
Purpose
You must tell users why data is being collected and you must not use that data
for other purposes.
Consent
You must always have the consent of a user before you disclose their data to
other people.
Data lifetime
You must not keep data for longer than you need to. If a user deletes their
account, you must delete the personal data associated with that account.
Secure storage
You must maintain data securely so that it cannot be tampered with or disclosed
to unauthorized people.
Location
You must not store data in countries where weaker data protection laws apply
unless there is an explicit agreement that the stronger data protection rules will
be upheld.
• You should to establish a privacy policy that defines how personal and sensitive
information about users is collected, stored and managed.
• Software products use data in different ways, so your privacy policy has to define
the personal data that you will collect and how you will use that data.
• Product users should be able to review your privacy policy and change their
preferences regarding the information that you store.
• Your privacy policy is a legal document and it should be auditable to check that it is
consistent with the data protection laws in countries where your software is sold.
• Privacy policies should not be expressed to users in a long ‘terms and conditions’
document that, in practice, nobody reads.
• The GDPR now require software companies to include a summary of their privacy
policy, written in plain language rather than legal jargon, on their website.
• Common types of attack on software products include injection attacks, cross-site scripting
attacks, session hijacking attacks, denial of service attacks and brute force attacks.
• Authentication may be based on something a user knows, something a user has, or some
physical attribute of the user.
• Symmetric encryption involves encrypting and decrypting information with the same secret
key. Asymmetric encryption uses a key pair – a private key and a public key. Information
encrypted using the public key can only be decrypted using the private key.
• A major issue in symmetric encryption is key exchange. The TLS protocol, which is
used to secure web traffic, gets around this problem by using asymmetric encryption
for transferring information used to generate a shared key.
• If your product stores sensitive user data, you should encrypt that data when it is not
in use.
• A key management system (KMS) stores encryption keys. Using a KMS is essential
because a business may have to manage thousands or even millions of keys and may
have to decrypt historic data that was encrypted using an obsolete encryption key.
• Privacy is a social concept that relates to how people feel about the release of their
personal information to others. Different countries and cultures have different ideas on
what information should and should not be private.
• Data protection laws have been made in many countries to protect individual privacy.
They require companies who manage user data to store it securely, to ensure that it is
not used or sold without the permission of users, and to allow users to view and
correct personal data held by the system.