Skip to main content
INFO Threat Intel #Incident Response

Linux Shell Forensics: Investigating Atuin History in Incident Response

5 min read Runtime Rebel Intel
Primary source: isc.sans.edu

This article was written by a language model from the source above and was not reviewed by a human before publication. Verify anything operational against the original. Editorial policy

Key points
  • Forensically examining Linux systems using Atuin requires specialized knowledge to prevent loss of critical evidence.
  • Linux systems where users have installed and enabled the Atuin shell history management tool are affected.
  • Investigators must learn to identify Atuin artifacts and analyze its SQLite database and configuration files.

Advertisement

Atuin: Enhancing Shell History and Forensic Implications

Traditional UNIX-like systems, including Linux, record extensive activity logs in various locations. However, standard shells often lack modern, detailed logging for user commands, typically relying on a simple flat file like ~/.bash_history. These traditional history files have significant limitations for forensic analysis, such as minimal context and easy modification or deletion.

Atuin emerges as a popular tool designed to enhance shell history capabilities, fundamentally changing the landscape for forensic investigations on Linux systems. It augments the standard shell history by storing commands and additional context within a SQLite database. This database records crucial details per command, including its timestamp, execution duration, exit code, session identifier, host, and current working directory, vastly improving the data available compared to basic history files. Furthermore, Atuin offers end-to-end encrypted synchronization of history across multiple machines, either via an official server or a self-hosted instance.

From a forensic standpoint, Atuin presents a dual challenge and opportunity. As highlighted by SANS ISC, if an investigator is unaware of Atuin’s presence, significant evidence could be overlooked. Conversely, its detection and proper analysis can yield a rich trove of detailed activity data, making it a valuable resource during incident response.

Detecting Atuin Artifacts on Linux

Identifying the use of Atuin early in a forensic investigation is critical. Atuin generally adheres to XDG Base Directory Specification paths. Therefore, investigators should examine standard locations such as ~/.local/share/atuin for the SQLite database and ~/.config/atuin for configuration files within each user’s home directory, as well as the root user’s home directory.

It is crucial not to assume default locations. Atuin allows for highly customizable paths through environment variables and its config.toml file. The $ATUIN_CONFIG_DIR environment variable can override the configuration location, and the database, encryption key, and session paths can all be individually configured within config.toml. Therefore, reading this configuration file first is a recommended step to accurately locate all relevant artifacts. Proof-of-activation for Atuin can also be found in shell RC files (e.g., .bashrc, .zshrc) where its initialization hook must be enabled for each shell and user. Understanding how Atuin is integrated and configured is paramount for a comprehensive Atuin shell history forensic investigation.

Analyzing Atuin’s SQLite History Database

The core forensic value of Atuin lies within its SQLite database, typically named history.db. The primary table of interest is history, which contains a wealth of information compared to flat file histories. Each entry includes:

  • id: A client-generated identifier, used for synchronization.
  • timestamp: When the command was executed.
  • duration: How long the command ran.
  • exit_code: The command’s exit status.
  • cwd: The current working directory at execution time.
  • host: The hostname where the command was run.
  • session: A unique identifier for the shell session.
  • command: The actual command string.

One of Atuin’s most significant forensic features is its “soft-delete” mechanism. Instead of physical deletion, rows marked for deletion are updated with a deleted_at timestamp in the history table. This means that commands “deleted” by the user via Atuin’s interface are not immediately purged from the database. Forensicators can recover this “deleted” activity by querying the database with WHERE deleted_at IS NOT NULL.

Beyond this soft-delete recovery, standard SQLite carving techniques apply. Investigators can use tools like undark or bring2lite, or perform manual page carving, to recover prior row versions and dropped records from the database’s freelist, unallocated pages, and Write-Ahead Log (WAL) files. This can potentially reveal even more transient or intentionally obscured command history. Crucially, Atuin typically writes its detailed history alongside the standard flat history files (e.g., ~/.bash_history), providing an excellent opportunity for cross-referencing and validation of findings.

Investigating Atuin’s Sync Feature

Atuin’s synchronization feature, if enabled, can be a valuable source of evidence. The config.toml file will indicate if auto_sync = true. If synchronization is active and the user is authenticated, history is end-to-end encrypted and pushed to a server (by default, https://api.atuin.sh). If the investigator gains access to the authentication credentials and the encryption key, historical data may be pullable back from the server. For self-hosted Atuin servers, more server-side evidence may be available, though raw data will still be encrypted.

Gaps in Atuin Data Collection

Investigators must also be aware of potential gaps in Atuin’s recorded history. The config.toml allows users to specify commands that should never be recorded via the ignore_commands directive. Therefore, the absence of a particular command in the Atuin database is not conclusive evidence that it was never executed. Additionally, Atuin primarily logs interactive shell sessions where its init hook is loaded. Commands run in non-interactive shells, scripts, or sh sessions without the Atuin hook will not be captured by the tool, though they might still appear in other system logs or traditional history files.

Actionable Recommendations for Forensic Investigators

  • Prioritize Atuin Detection: Make identification of Atuin installation a routine early step in any Linux incident response or forensic investigation.
  • Examine config.toml: Thoroughly review the Atuin configuration file for custom paths ($ATUIN_CONFIG_DIR, db_path, key_path, session_path), sync settings (auto_sync), ignore_commands, and server details. This is essential for accurately locating artifacts and understanding data collection parameters.
  • Recover Soft-Deleted Entries: Utilize SQL queries targeting the deleted_at IS NOT NULL field in the history table to uncover activity that users attempted to remove.
  • Apply SQLite Carving: Employ specialized forensic tools or techniques to analyze the SQLite database’s freelist, unallocated space, and WAL files for deeper data recovery.
  • Cross-Reference Data: Always compare Atuin’s detailed history with traditional flat history files (.bash_history, .zsh_history) and system-wide logs (syslog, journald) to build a comprehensive timeline and validate findings.
  • Investigate Sync Servers: If auto_sync is enabled, explore the possibility of recovering encrypted history from the configured sync server, provided authentication and encryption keys can be obtained.

Related: zipdump.py: Challenges in Metadata Encoding, Post-Exploitation Tactics: Persistence and Lateral Movement Analysis

Advertisement

Advertisement