Command-line Risk Classification using Transformer-based Neural Architectures

Paolo Notaro, Soroush Haeri, Jorge Cardoso, Michael Gerndt · 2024

Read Command-line Risk Classification using Transformer-based Neural Architectures by Paolo Notaro, Soroush Haeri, Jorge Cardoso, Michael Gerndt (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-01655.txt.

Introduction

Notaro, Haeri, Cardoso, and Gerndt present a paper from twenty twenty-four on grading command-line risk with transformer models. Cloud operators intercept typed commands to block dangerous ones before harm. Rule lists need constant expert upkeep and miss novel commands. Generic text classifiers fit scripting languages poorly and overlook rare threats. Their system adapts a large language model through transfer learning. It learns the quirks of shell languages like Bash and PowerShell. Tests use a realistic set of production commands.

The model flags rare dangerous commands well despite skewed data. It can also audit old rule lists for gaps. Dangerous command interception is a second shown use. The authors pitch learning over hand-kept rules for operations safety.

Catalog record

CREATORPaolo Notaro, Soroush Haeri, Jorge Cardoso, Michael Gerndt
YEAR2024
COLLECTIONPAPERS
FORMATTXT
FILE SIZE32 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2412-01655

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Command-line Risk Classification using Transformer-based Neural Architectures Paolo Notaro, Soroush Haeri, Jorge Cardoso, Michael Gerndt Abstract To protect large-scale computing environments necessary to meet increasing computing demand, cloud providers have implemented security measures to monitor Operations and Maintenance (O&M) activities and therefore prevent data loss and service interruption. Command interception systems are used to intercept, assess, and block dangerous Command-line Interface (CLI) commands before they can cause damage. Traditional solutions for command risk assessment include rule-based systems, which require expert knowledge and constant human revision to account for unseen commands. To overcome these limitations, several end-to-end learning systems have been proposed to classify CLI commands. These systems, however, have several other limitations, including the adoption of general-purpose text classifiers, which may not adapt to the language characteristics of scripting languages such as Bash or PowerShell, and may not recognize dangerous commands in the presence of an unbalanced class distribution. In this paper, we propose a transformer-based command risk classification system, which leverages the generalization power of Large Language Models (LLM) to provide accurate classification and the ability to identify rare dangerous commands effectively, by exploiting the power of transfer learning. We verify the effectiveness of our approach on a realistic dataset of production commands and show how to apply our model for other security-related tasks, such as dangerous command interception and auditing of existing rule-based systems. Introduction The growth of security threats has encouraged organizations to develop effective security solutions to safeguard digital applications, data and resources [ 1 , 2 , 3 ] . Solutions target the prevention of incidents and malicious attacks. In large IT systems, Operations and Maintenance (O&M) personnel accesses remote production systems to configure and repair services. O&M operators execute thousands of operations each day, and incorrect or malicious commands can cause major system failures and data losses resulting in high monetary and reputation costs. Security solutions are required to prevent any service impact or infrastructural damage by recognizing potentially dangerous operations before they are executed. A typical solution is to mediate the access to production systems through a bastion host [ 4 ] . Command Risk Class Notes rm 2023-04-21_12:45:67.log LOW deletes temporary log rm -rf /bin/* HIGH (force) deletes executables dir cat $DELETE_LIST | grep *.log LOW prints filtered content cat $DELETE_LIST | xargs -0 rm HIGH deletes files from input file time ls LOW (timed) cwd directory listing time kill -9 12345 HIGH process kill hidden by time call echo ‘kill 7890’ LOW prints a string echo ` kill 7890 ` HIGH backtick evaluates kill Table 1: Examples of commands with varying complexity and risk. It can be easily observed how small changes to parameters, flags, and some uses of the command-line syntax highly influence the risk of executed commands. The evaluation of command risk is an open and challenging problem, due to large variability in executable programs and their combination of arguments, flags, and environment variables (see Table 1 ). Rule-based classifiers are simple and frequently adopted solutions for this problem - however, in large-scale environments, they require to regular maintenance and revision of existing rules to reflect the dynamism of the environment. Previous works in Natural Language Processing (NLP) have shown the high capabilities provided by machine learning approaches, and specifically Large Language Models (LLMs), on a variety of NLP-related tasks [ 5 ] . Their double learning procedure, based on pretraining the model on a large-scale, domain-specific corpus of text, and finetuning the model for the specific task with supervised data, allows to provide higher context understanding and generalization power than previous NLP algorithms. Some previous works in the context of O&M security [ 2 , 6 ] have applied machine learning to command-line data for security-related classification tasks, such as malicious command detection. However, no previous approach has considered the potentiality of LLMs for command classification, or it has tried to adapt existing LLM-powered solutions for text classification for the CLI security domain. To this end, we propose the use of a transfer-learning, transformer-based method for the command risk classification task. Our main contribution is a language model pretrained on large corpus of command-line language data, which can be adapted for several language-related tasks via finetuning. Using a curated dataset of real-world production commands, we applied our language model for command risk classification, where we can obtain risk predictions that are more accurate and more sensitive towards potentially dangerous commands. Being our model trained end-to-end to process and classify commands, it does not rely on manual verification from humans during runtime and it provides 100% classification, differently from rule-based systems. We evaluate and compare our approach to existing algorithms for command risk classification. Results show that our approach improves detection of dangerous commands, and it is particularly able to pinpoint highly dangerous commands more effectively (F1-score +22%), albeit such commands are extremely rare and thus limited in the training data. We also describe how to apply our pretrained command-line language model for other security-related tasks. The rest of the paper is organized as follows. In Section Background , we present foundations on command-line security and related work. In Section Approach , the proposed approach is presented, followed by Experimental Setup and experimental Results . In Section Use Cases , we discuss for ourthe applicability of our approach in the context of cloud security. We summarize the outcome of the paper in the Conclusion . Background In this section we present the foundations of command-line security and the command risk classification problem ( Command-line Security ) and a summary of related work ( Related Work ). Command-line Security Figure 1: Architecture of a rule-based risk assessment system. Commands executed by operators are intercepted by a bastion host (Bastion SSH) to be evaluated using a set of rules stored in a configuration DB (Rule Management). If the command is evaluated safe, it is forwarded to the Target Host, otherwise an error is reported. All risk evaluations are logged and periodically revised by security experts, who may update the rules. Large-scale computing environments require high levels of availability and reliability to fulfill Service Level Agreements (SLA). Due to the large scale of devices and services being executed, failures are, albeit rare, inevitable. To this end, Operation and Maintenance (O&M) personnel operates to resolve and minimize the impact of failures on the correct runtime of computing services. O&M requires operators to access remote systems to configure and repair services via Command-line Interface (CLI). Providing free access to remote production systems poses two major security challenges, namely 1) the possibility of external attackers gaining unauthorized access to systems and 2) the possibility of operators accidentally performing harmful operations and damage service availability. For this reason, operators typically access remote hosts via a bastion host, which allows to review, approve, and execute commands without establishing direct connection to systems [ 4 ] . Bastion hosts implement an interception system, which captures executed commands and analyses them before granting execution rights. The need to recognize and block dangerous commands before their execution requires an algorithm to estimate command risk. Different risk classes may be defined, and each class may be associated with the necessary privilege to execute commands. Command risk classification is then the association

Read the complete text