Lesson 14 Flashcards
application attacks
- Attacks that target vulnerabilities in application code or architecture/design
- Privilege escalation
- Get privileges from target vulnerable process to run arbitrary code
- Remote execution when code is transferred from another machine
- Vertical and horizontal privilege escalation
- Detect by process logging and auditing plus automated detection scanning
- Error handling
- Identify attack from error messages
- Leaking information through errors
- Improper input handling
•Privilege escalation (application attacks)
The purpose of most application attacks is to allow the threat actor to run his or herown code on the system. This is referred to as arbitrary code execution. Where the code is transmitted from one machine to another, it can be referred to as remote code execution. The code would typically be designed to install some sort of backdoor or to disable the system in some way (denial of service).
arbitrary code execution
The purpose of most application attacks is to allow the threat actor to run his or her
own code on the system. This is referred to as arbitrary code execution.
remote code execution.
Where the code is transmitted from one machine to another, it can be referred to as remote code
execution. The code would typically be designed to install some sort of backdoor or to
disable the system in some way (denial of service).
Two types of privilidge escalation
If a software exploit
works, the attacker may be able to execute arbitrary code with the same privilege level as
the exploited process. There are two main types of privilege escalation:
- Vertical privilege escalation
- Horizontal privilege escalation
- Vertical privilege escalation
Vertical privilege escalation (or elevation) is where a user or application can
access functionality or data that should not be available to them. For instance, a
process might run with local administrator privileges, but a vulnerability allows the
arbitrary code to run with higher system privileges.
- Horizontal privilege escalation
Horizontal privilege escalation is where a user accesses functionality or data
that is intended for another user. For instance, via a process running with local
administrator privileges on a client workstation, the arbitrary code is able to execute
as a domain account on an application server.
How to detect priviledge escalation
- Detect by process logging and auditing plus automated detection scanning
Without performing detailed analysis of code or process execution in real time, it is
privilege escalation that provides the simplest indicator of an application attack. If process
logging has been configured (varonis.com/blog/sysmon-threat-detection-guide), the audit
log can provide evidence of privilege escalation attempts. These attempts may also be
detected by incident response and endpoint protection agents, which will display an alert.
Error Handling
- Identify attack from error messages
- Leaking information through errors
An application attack may cause an error message. In Windows, this may be of the following types: “Instruction could not be read or written,” “Undefined exception,”or “Process has encountered a problem.” One issue for error handling is that the
application should not reveal configuration or platform details that could help an
attacker. For example, an unhandled exception on a web application might show an
error page that reveals the type and configuration of a database server.
Improper input handling
Most software accepts user input of some kind, whether the input is typed manually or
passed to the program by another program, such as a browser passing a URL to a web
server or a Windows process using another process via its application programming
interface.
Good programming practice dictates that input should be tested to ensure
that it is valid; that is, the sort of data expected by the receiving process.
Mostapplication attacks work by passing invalid or maliciously constructed data to the
vulnerable process. There are many ways of exploiting improper input handling, but
many attacks can be described as either overflow-type attacks or injection-type attacks.
overflow attack
the threat actor submits input that is too large to be stored in a variable assigned by the application
Ideally, the
code used to attempt these attacks will be identified by network IDS or by an endpoint
protection agent. Unsuccessful attempts may be revealed through unexplained crashes
or error messages following a file download, execution of a new app or a script, or
connection of new hardware.
Buffer Overflow
[There is a diagram in the guide that is a little helpful]
- Buffer is memory allocated to application
- Overflows can allow arbitrary code to execute
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. The stack is an
area of memory used by a program subroutine. It includes a return address, which is the
location of the program that called the subroutine. An attacker could use a buffer overflow
to change the return address, allowing the attacker to run arbitrary code on the system.
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 is a positive or negative number with no fractional component (a whole number). Integers are widely used as a data type, where they are commonly defined
with fixed lower and upper bounds. 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, for instance). It could
also be used where the software is calculating a buffer size; if the attacker is able to
make the buffer smaller than it should be, he or she may then be able to launch a
buffer overflow attack.
Null Pointer Dereferencing and Race Conditions
[I did not understand this one]
- Pointers are used in C/C++ to refer to memory locations
- Dereferencing occurs when the program tries to read or write the location via the pointer
- If the location is null or invalid, the process will crash
- Race condition
- Execution depends on timing and sequence of events
- Time of check/time of use (TOCTTOU)
- Environment is manipulated to change a resource after checking but before use
Memory Leaks
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
Resource exhaustion
- CPU time, system memory allocation, fixed disk capacity, and network utilization
- Spawning activity to use up these resources
A malicious process could spawn multiple looping threads to use up CPU time, or write
thousands of files to disk. Distributed attacks against network applications perform a
type of resource exhaustion attack by starting but not completing sessions, causing
the application to fill up its state table, leaving no opportunities for genuine clients
to connect.
Dynamic Link Library (DLL)
•Dynamic Link Library (DLL) implements some function that multiple processes can use
A dynamic link library (DLL) is a binary package that implements some sort of standard
functionality, such as establishing a network connection or performing cryptography.
The main process of a software application is likely to load several DLLs during the
normal course of operations.
DLL Injection
•DLL injection forces a process to load malicious DLL
DLL injection is a vulnerability in the way the operating system allows one process to
attach to another. This functionality can be abused by malware to force a legitimate
process to load a malicious link library. The link library will contain whatever functions
the malware author wants to be able to run. Malware uses this technique to move from
one host process to another to avoid detection.
Refactoring
Refactoring might allow code obfuscation to elude anti-virus (DLL Injection)
Shim
•Exploit application compatibility framework to allow malware to persist on host
Another opportunity for malware authors to exploit
these calls is the Windows Application Compatibility framework. This allows legacy
applications written for an OS, such as Windows XP, to run on later versions. The code
library that intercepts and redirects calls to enable legacy mode functionality is called a
shim. The shim must be added to the registry and its files (packed in a shim database/
.SDB file) added to the system folder. The shim database represents a way that
malware with local administrator privileges can run on reboot (persistence).
application compatibility framework
Windows Application Compatibility framework. This allows legacy
applications written for an OS, such as Windows XP, to run on later versions.
pass the hash
- Exploiting cached credentials to perform lateral movement
- Windows hosts cache credentials in memory as NTLM hashes
- Local malicious process with administrator privileges can dump these hashes
- 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
URL Analysis
- Uniform Resource Locator (URL) format
- HTTP methods
- TCP connections
- GET, POST, PUT, HEAD
- POST or PUT
- URL (query parameters)
- Fragment/anchor ID
- HTTP response codes
- Percent encoding
•Uniform Resource Locator (URL) format
There is a diagram inthe guide