Native API

Adversaries may interact with the native OS application programming interface (API) to execute behaviors. Native APIs provide a controlled means of calling low-level OS services within the kernel, such as those involving hardware/devices, memory, and processes.(Citation: NT API Windows)(Citation: Linux Kernel API) These native APIs are leveraged by the OS during system boot (when other system components are not yet initialized) as well as carrying out tasks and requests during routine operations.

Adversaries may abuse these OS API functions as a means of executing behaviors. Similar to [Command and Scripting Interpreter](https://attack.mitre.org/techniques/T1059), the native API and its hierarchy of interfaces provide mechanisms to interact with and utilize various components of a victimized system.

Native API functions (such as <code>NtCreateProcess</code>) may be directed invoked via system calls / syscalls, but these features are also often exposed to user-mode applications via interfaces and libraries.(Citation: OutFlank System Calls)(Citation: CyberBit System Calls)(Citation: MDSec System Calls) For example, functions such as the Windows API <code>CreateProcess()</code> or GNU <code>fork()</code> will allow programs and scripts to start other processes.(Citation: Microsoft CreateProcess)(Citation: GNU Fork) This may allow API callers to execute a binary, run a CLI command, load modules, etc. as thousands of similar API functions exist for various system operations.(Citation: Microsoft Win32)(Citation: LIBC)(Citation: GLIBC)

Higher level software frameworks, such as Microsoft .NET and macOS Cocoa, are also available to interact with native APIs. These frameworks typically provide language wrappers/abstractions to API functionalities and are designed for ease-of-use/portability of code.(Citation: Microsoft NET)(Citation: Apple Core Services)(Citation: MACOS Cocoa)(Citation: macOS Foundation)

Adversaries may use assembly to directly or in-directly invoke syscalls in an attempt to subvert defensive sensors and detection signatures such as user mode API-hooks.(Citation: Redops Syscalls) Adversaries may also attempt to tamper with sensors and defensive tools associated with API monitoring, such as unhooking monitored functions via [Disable or Modify Tools](https://attack.mitre.org/techniques/T1562/001).

Platforms: Windows
macOS
Linux
Tactics:
phase_name: execution

Detection:
Monitoring API calls may generate a significant amount of data and may not be useful for defense unless collected under specific circumstances, since benign use of API functions are common and may be difficult to distinguish from malicious behavior. Correlation of other events with behavior surrounding API function calls using API monitoring will provide additional context to an event that may assist in determining if it is due to malicious behavior. Correlation of activity by process lineage by process ID may be sufficient. 

Utilization of the Windows APIs may involve processes loading/accessing system DLLs associated with providing called functions (ex: ntdll.dll, kernel32.dll, advapi32.dll, user32.dll, and gdi32.dll). Monitoring for DLL loads, especially to abnormal/unusual or potentially malicious processes, may indicate abuse of the Windows API. Though noisy, this data can be combined with other indicators to identify adversary activity. 

References:
source_name: mitre-attack
description: Apple. (2015, September 16). Cocoa Application Layer. Retrieved June 25, 2020.
source_name: MACOS Cocoa
description: Apple. (n.d.). Core Services. Retrieved June 25, 2020.
source_name: Apple Core Services
description: Apple. (n.d.). Foundation. Retrieved July 1, 2020.
source_name: macOS Foundation
description: de Plaa, C. (2019, June 19). Red Team Tactics: Combining Direct System Calls and sRDI to bypass AV/EDR. Retrieved September 29, 2021.
source_name: OutFlank System Calls
description: Feichter, D. (2023, June 30). Direct Syscalls vs Indirect Syscalls. Retrieved September 27, 2023.
source_name: Redops Syscalls
description: Free Software Foundation, Inc.. (2020, June 18). Creating a Process. Retrieved June 25, 2020.
source_name: GNU Fork
description: Gavriel, H. (2018, November 27). Malware Mitigation when Direct System Calls are Used. Retrieved September 29, 2021.
source_name: CyberBit System Calls
description: glibc developer community. (2020, February 1). The GNU C Library (glibc). Retrieved June 25, 2020.
source_name: GLIBC
description: Kerrisk, M. (2016, December 12). libc(7) — Linux manual page. Retrieved June 25, 2020.
source_name: LIBC
description: Linux Kernel Organization, Inc. (n.d.). The Linux Kernel API. Retrieved June 25, 2020.
source_name: Linux Kernel API
description: MDSec Research. (2020, December). Bypassing User-Mode Hooks and Direct Invocation of System Calls for Red Teams. Retrieved September 29, 2021.
source_name: MDSec System Calls
description: Microsoft. (n.d.). CreateProcess function. Retrieved December 5, 2014.
source_name: Microsoft CreateProcess
description: Microsoft. (n.d.). Programming reference for the Win32 API. Retrieved March 15, 2020.
source_name: Microsoft Win32
description: Microsoft. (n.d.). What is .NET Framework?. Retrieved March 15, 2020.
source_name: Microsoft NET
description: The NTinterlnals.net team. (n.d.). Nowak, T. Retrieved June 25, 2020.
source_name: NT API Windows