Application Security Fundamentals Flashcards
What is application security?
The primary defense in application security involves integrating security throughout the entire software lifecycle, from planning and development to implementation. Approaches like DevSecOps build on the Secure Software Development Lifecycle (SSDLC) to integrate security at each phase, leveraging DevOps’ iterative automation processes and fostering a culture of collective security ownership. Key elements include threat modeling, secure coding practices, and automated security testing. These measures reduce the attack surface before deployment. Post-deployment, continuous monitoring, regular patching, incident response planning, and compliance checks ensure any residual vulnerabilities are promptly addressed.
It includes:
- Secure Coding: Writing code to avoid vulnerabilities like SQL injection and XSS.
- Threat Modelling: Identifying potential threats and designing defences.
- Vulnerability Testing: Using tools like SAST, DAST, and IAST to find and fix vulnerabilities.
- Patch Management: Regularly updating the application and its components.
- Authentication & Authorisation: Ensuring proper identity verification and access control.
- Encryption: Protecting data in transit and at rest.
- Logging & Monitoring: Tracking and analysing application activity for signs of threats.
- Incident Response: Planning for and managing security breaches.
- Compliance: Adhering to relevant regulations and standards.
Application security is crucial to prevent breaches, data loss, and unauthorised access.
Why is application security important?
Applications security is important because:
- Guaranteeing the security of sensitive information
- Developing user trust and boosting reputation
- Mitigating the potential for attacks
What is the difference between DevSecOps and a Secure Software Development Lifecycle (SSDLC)?
DevSecOps vs. SSDLC:
-
SSDLC (Secure Software Development Lifecycle):
- Approach: Structured, sequential process integrating security at every stage (planning, design, development, testing, deployment, maintenance).
- Focus: Formal security practices, often more manual and phase-driven.
- Methodology: Traditional, linear with defined phases.
-
DevSecOps:
- Approach: Iterative, continuous integration of security within DevOps pipelines.
- Focus: Automation, speed, and collaboration; security is everyone’s responsibility.
- Methodology: Agile, automated, and culture-driven, aligning with continuous delivery models.
Comparison:
- SSDLC is more formal and phase-driven, often with manual processes.
- DevSecOps operationalizes SSDLC principles in a continuous, automated, and collaborative environment, suited for fast-paced DevOps cultures.
What are the common threats for applications?
- SQL Injection: Malicious SQL statements are injected into an entry field to manipulate the database.
- Cross-Site Scripting (XSS): Attackers inject malicious scripts into web pages viewed by other users, leading to data theft or session hijacking.
- Cross-Site Request Forgery (CSRF): Forces a user to execute unwanted actions on a web application where they are authenticated, potentially leading to unauthorized actions.
- Security Misconfiguration: Improperly configured security settings, such as default passwords or open ports, leaving applications vulnerable to attack.
- Buffer Overflow: Occurs when more data is written to a buffer than it can hold, potentially allowing attackers to overwrite memory and execute arbitrary code.
What is cross-site scripting (XSS)?
Cross-Site Scripting (XSS) is a type of security vulnerability typically found in web applications. It occurs when an attacker injects malicious scripts (usually JavaScript) into content that is delivered to other users. The script can then be executed in the context of the victim’s browser, leading to various malicious activities such as data theft, session hijacking, or defacement of the website.
The Three Most Common Types of XSS:
-
Stored XSS (Persistent XSS):
- Description: The malicious script is permanently stored on the target server, such as in a database, forum post, or comment field. When a user views the infected content, the script is delivered and executed in their browser.
Example: An attacker posts a comment containing malicious script on a forum. Every time someone reads that comment, the script runs in their browser.
-
Reflected XSS (Non-Persistent XSS):
- Description: The malicious script is reflected off a web server, usually in error messages, search results, or other responses that include user input. The script is not stored but is instead immediately delivered to the victim.
Example: An attacker sends a link with a malicious script embedded in the URL to a user. When the user clicks the link, the script is reflected off the server and executed in their browser.
-
DOM-Based XSS:
- Description: The vulnerability is in the client-side code (JavaScript), where the script is executed directly by modifying the Document Object Model (DOM) of the page. This type of XSS occurs when the client-side script processes user input and updates the DOM without proper validation.
Example: An attacker manipulates the URL or other inputs that are processed by client-side JavaScript, which in turn dynamically updates the page content and executes the malicious script.
Summary:
- Stored XSS: Malicious script is stored on the server and delivered to users when they view the content.
- Reflected XSS: Malicious script is reflected off the server and delivered via a request (e.g., a URL).
- DOM-Based XSS: Malicious script is executed by manipulating the client-side DOM directly, without involving the server.
What are the various types of application misconfigurations?
Some of the major causes of application vulnerabilities include:
- Incorrect file permissions or ownership settings.
- Inadequate hardening of applications and systems.
- Insecure databases, particularly concerning access rights.
- Outdated or unpatched software.
- Misconfigurations or resets due to updates.
- Debugging information exposing sensitive data.
- Insufficient testing of application code, leading to security gaps.
What is SQL injection (SQLi)?
SQL Injection is a web security vulnerability where an attacker inserts malicious SQL code into a query, allowing them to manipulate the database, access unauthorised data, or perform other harmful actions.
Types of SQL Injection:
-
Classic SQL Injection:
- Directly manipulates SQL queries by injecting malicious input through user input fields.
-
Blind SQL Injection:
- The attacker cannot see the results of the SQL injection directly but infers information based on the web application’s responses (e.g., true/false responses).
-
Error-Based SQL Injection:
- Exploits error messages from the database to gather information about the structure of the database.
-
Union-Based SQL Injection:
- Combines results from multiple SELECT statements into a single result, allowing attackers to extract data from different tables.
-
Time-Based SQL Injection:
- Uses SQL commands that cause a delay, allowing the attacker to infer information based on the time taken to respond.
What is buffer overflow?
Buffer Overflow is a security vulnerability that occurs when more data is written to a buffer (a temporary data storage area) than it can hold. This can lead to adjacent memory areas being overwritten, potentially allowing an attacker to execute arbitrary code or crash the system.
Types of Buffer Overflow:
-
Stack Overflow:
- Occurs in the call stack when more data is written to a stack buffer than it can handle, often leading to control flow hijacking.
-
Heap Overflow:
- Happens in the heap memory area, where excess data overwrites adjacent memory, potentially corrupting data or allowing code execution.
-
Unicode Overflow:
- Exploits vulnerabilities in handling Unicode characters, often leading to buffer overflows due to incorrect assumptions about character size.
-
Integer Overflow:
- Occurs when an arithmetic operation results in a value larger than the allocated space can handle, potentially leading to buffer overflows if the value is used in memory allocation or indexing.
What is cross-site request forgery (CSRF)?
Cross-Site Request Forgery (CSRF) is a web security vulnerability where an attacker tricks a user into performing an unwanted action on a web application in which they are authenticated. For example, the attacker could craft a malicious link or form that, when visited or submitted by the victim, causes the victim’s browser to make a request to the application, performing actions like changing account details or making a purchase without the user’s consent.
Mitigations:
-
CSRF Tokens:
- Include unique, unpredictable tokens in requests that change state (e.g., form submissions). The server checks for the presence and validity of the token before processing the request.
-
SameSite Cookies:
- Configure cookies with the
SameSite
attribute, which restricts how cookies are sent with cross-site requests, helping to prevent CSRF attacks.
- Configure cookies with the
-
Double Submit Cookies:
- Include a CSRF token in both a cookie and as a request parameter, with the server validating that both tokens match.
-
Referer and Origin Header Checks:
- Validate the
Referer
orOrigin
headers in requests to ensure they come from trusted sources.
- Validate the
-
User Interaction Verification:
- Require additional confirmation for critical actions, such as password changes, to ensure they are intended by the user.
What is the OWASP Application Security Verification Standard (ASVS) used for?
It was developed with the following objectives:
- As a metric: To provide application developers and owners with a benchmark to assess how trustworthy their applications are.
- As guidance: To offer developers clear instructions on which security controls to implement to meet security requirements.
- For procurement: To serve as a foundation for specifying application security verification requirements in contracts.
What are the best practices for incorporating secure frameworks and/or libraries in applications?
Best practices for using secure frameworks and libraries include:
- Reuse: Only utilise frameworks and libraries from actively maintained sources that are widely adopted by other applications.
- Catalogue: Maintain an inventory of all third-party code libraries as they are integrated.
- Check: Regularly verify that all code components and libraries are up to date, using dependency-checking tools to identify and address known vulnerabilities.
- Reduce: Minimise vulnerabilities and the attack surface by reusing only the necessary portions of code required for specific functions and behaviour.
What scenarios are application hardening techniques typically used for?
Application hardening techniques are commonly employed for the following purposes:
- Protecting against reverse-engineering of the application back to its source code.
- Preventing the inspection of internal values, as well as monitoring or tampering with the application.
- Ensuring the application can securely operate in zero-trust environments.
- Safeguarding data and sensitive information.
What are the typical application hardening techniques?
Code Obfuscation (Including Binary Code Obfuscation)
- Description: Obfuscation makes source code and binary code difficult to understand for anyone attempting to reverse-engineer the application. It alters variable names, control structures, and logic flows while maintaining functionality.
- Binary Code Obfuscation: Specifically targets compiled binary files, making it harder for attackers to decompile and analyse the code or retrieve sensitive information.
White Box Cryptography
- Description: Involves encrypting data in a way that remains secure even if the attacker has full visibility of the algorithm, key, and execution environment. This method ensures that sensitive cryptographic operations are difficult to extract or manipulate, even in compromised environments.
Anti-Debugging
- Description: Techniques that detect and prevent the use of debugging tools on an application. This can include checks that look for attached debuggers or the presence of breakpoints, and, if detected, can either terminate the application or change its behaviour to prevent analysis.
Anti-Tampering
- Description: Measures designed to detect and respond to any attempt to alter the application’s code or behaviour. This may involve verifying the integrity of the code, and if tampering is detected, the application can either terminate or restrict access to critical features.
Integrity Checkers
- Description: Tools or routines that periodically verify the integrity of application files, code, or configuration settings. If any unauthorised modifications are detected, the application can respond by restoring the original state, alerting the user, or shutting down.
Anti-Rooting
- Description: Security measures that detect if an Android device has been rooted (i.e., granted superuser privileges), which could allow attackers to bypass security controls. If rooting is detected, the application may refuse to run or limit functionality.
Jailbreak Protection
- Description: Similar to anti-rooting, jailbreak protection is designed to detect if an iOS device has been jailbroken (i.e., modified to remove Apple’s restrictions). Jailbroken devices pose a higher security risk, and applications often restrict functionality or refuse to run on such devices.
Runtime Application Self-Protection (RASP)
- Description: RASP embeds security into the application itself, monitoring its behaviour during runtime and providing real-time protection. It can block attacks as they occur, based on behavioural patterns and environmental conditions.RASP Features:
-
Anti-Screen Readers:
Prevents attackers from using screen readers or accessibility services to extract sensitive information displayed on the screen. -
Anti-Keylogging:
Protects against keylogging attacks by preventing third-party applications from capturing sensitive data entered via the keyboard. -
Device Binding:
Ensures the application can only run on the device it was originally installed on, preventing attackers from transferring the app to another device for analysis or exploitation. -
Anti-Hooking:
Blocks attempts by attackers to attach themselves to the application and execute calls during its runtime, preventing them from interfering with the application’s processes. -
Anti-Emulator:
Detects and prevents the application from running in emulated or virtual environments, where attackers might trace its operations to discover vulnerabilities or reverse-engineer the application.
What are the factors you should consider when trying to secure a database?
Database security must consider the following factors:
- the data stored within the database,
- the database management system,
- any applications linked to the database (such as a web server),
- the database server or service,
- the underlying hardware (whether physical or part of a virtual environment),
- and the network infrastructure used to access the system.
What are the common mitigation techniques for application security threats?
Common mitigation techniques for application security threats include the following:
- Prepared Statements (SQL Injection Prevention): SQL injection attacks can be mitigated by using prepared statements (also known as parameterised queries). This ensures that user input is treated as data and not executable code, preventing attackers from manipulating SQL queries.
- Encoding and Escaping: Encoding and escaping are essential to prevent malicious data from being interpreted as executable code. For instance, encoding user inputs in web applications ensures that special characters are treated as plain text rather than commands. This is crucial for preventing various injection attacks.
-
Input Validation: Proper input validation is a fundamental security measure. There are two approaches:
- Whitelisting: Only allowing specific, predefined inputs that are known to be safe.
- Blacklisting: Blocking known malicious or suspicious inputs. Whitelisting is generally more secure, as it reduces the risk of missing new or unknown malicious inputs.
-
Cross-Site Scripting (XSS) Mitigation: To defend against XSS attacks, a combination of whitelisting and escaping characters can be used to sanitise user input. Additionally:
- Content-Security Policy (CSP): A CSP helps mitigate XSS attacks by controlling what resources a web page is allowed to load (e.g., scripts, styles). By specifying which sources are trusted, CSP prevents the browser from executing unauthorised or malicious scripts.
- HTTP-only Cookies: Setting cookies with the “HTTP-only” flag ensures that they cannot be accessed via JavaScript, reducing the risk of theft through XSS attacks.
- HTTPS and PKI Infrastructure: Using HTTPS (via SSL/TLS) ensures secure communication between the client and server by encrypting HTTP content, URLs, header information, and cookies. This prevents man-in-the-middle (MITM) attacks and ensures that sensitive data is protected. Public Key Infrastructure (PKI) helps verify the identity of websites, organisations, and individuals, further securing the connection.
By combining these techniques, applications can be better protected against a wide range of security threats, including SQL injection, XSS, and man-in-the-middle attacks.