Defense Evasion via Process Masquerading with Trailing Spaces
Adversaries utilize trailing space characters in binary filenames to masquerade as legitimate system tools, exploiting file handling behaviors to disguise malicious activity.
Adversaries employ a defense evasion technique involving the use of trailing space characters in the filenames of malicious binaries to mimic legitimate system executables. This masquerade exploits inconsistencies in how shells and system utilities handle file paths, allowing attackers to disguise malicious tools as common utilities like 'ssh', 'curl', or 'ps'. By placing these trojanized binaries within user-writable directories that appear early in the environment PATH, attackers can ensure their malicious versions are invoked instead of the legitimate counterparts. This technique is typically used to facilitate credential harvesting, payload staging, or persistence while avoiding detection by simple administrative review of process listings, as the trailing space can be visually subtle or stripped by certain monitoring tools.
Impact
Successful exploitation allows for stealthy execution of malicious code, unauthorized credential access, and the establishment of persistent backdoors via system utilities like cron or macOS LaunchAgents. If an attacker successfully replaces a core system utility, they may achieve broad persistence and maintain long-term access, often evading standard automated file handling mechanisms. This threat primarily affects Linux and macOS environments where PATH hijacking is a viable vector for privilege escalation and persistence.
Recommendation
Detection engineering teams should focus on identifying abnormal process names and suspicious file handling behaviors in the environment.
- Deploy the provided detection rule to monitor for process execution events where the process name ends with a space character.
- Audit and sanitize the system PATH for all users and services, removing user-writable directories from global PATH configurations.
- Implement file integrity monitoring (FIM) to detect the creation of files with trailing whitespace or Unicode characters in sensitive or PATH-indexed directories.
- Configure cron and launchd services to utilize strictly sanitized, absolute paths for all scheduled tasks.
Immediate actions
Deploy the 'Processes with Trailing Spaces' detection rule
Mitigations
Sanitize system PATH and apply stricter write protections to directories.
T1036.006
Detection coverage 1
Detect Processes with Trailing Spaces
lowDetects the execution of binaries whose names end with a space, used to mimic legitimate tools and evade detection.
Detection queries are available on the platform. Get full rules →