root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat ai-ml-security-threats.md
// AI Security

AI/ML Security Threats

14 Aug 2025 · 10 min read
This room walks through the intersection of AI/ML and cybersecurity. It is a conceptual walkthrough: it first lays the foundations of Artificial Intelligence, Machine Learning, neural networks and Transformer-based LLMs; it then studies the threats specific to AI systems (prompt injection, data poisoning, model theft) and how attacks themselves are supercharged by AI (malware, deepfakes, phishing); and it closes by showing how a defender can lean on an AI assistant to analyze logs, detect phishing and generate regex.
PlatformTryHackMe
CategoryAI Security
DifficultyEasy
RoomAI/ML Security Threats

Task 1 — Introduction

AI and ML are not just buzzwords: they are reshaping how both attackers and defenders operate. For defenders they bring efficiency and accuracy; for attackers they enable the automation of attacks at scale. This task only sets the scope of the room and requires no answer.

Task 2 — Building Blocks of AI

Artificial Intelligence (AI) is the branch of computer science that builds machines able to simulate human intelligence: reasoning (a chess-playing AI), natural language processing (chatbots like ChatGPT) or computer vision (an autonomous car recognizing traffic signs).

The term AI was first coined in the 1950s. Since then it has grown from rule-based systems into data-driven predictive systems.

Machine Learning (ML) is a subset of AI where the machine learns patterns from data instead of following explicit instructions. Its typical lifecycle is:

  1. Problem definition — state what needs solving (e.g. predicting spam emails).
  2. Data collection & preparation — gather quality datasets, handle missing values and clean noisy inputs.
  3. Feature engineering — turn raw data into meaningful input variables.
  4. Model training — apply algorithms (decision trees, neural networks).
  5. Evaluation & tuning — measure accuracy, precision, recall and F1-score, and tune hyperparameters.
  6. Deployment & monitoring — ship the model to production, watch for drift and retrain.

Categories of ML algorithms:

  • Supervised learning: labeled data → classification (spam / not spam) or regression (price prediction).
  • Unsupervised learning: unlabeled data → clustering or dimensionality reduction.
  • Semi-supervised learning: a mix of labeled and unlabeled data; improves accuracy when labeling is expensive.
  • Reinforcement learning: an agent learns by interacting with an environment and receiving rewards or penalties.

Q: What category of machine learning combines both labelled and unlabelled data?
A: Semi-supervised learning

Neural networks mimic the human brain through layers of interconnected nodes (neurons): an input layer that accepts raw data, hidden layers that transform it with activation functions, and an output layer that produces the prediction. Synapses are the weighted connections between neurons that simulate biological brain behavior. Deep Learning is the subset of ML that uses many hidden layers to extract features automatically, and it is especially powerful for images, speech and unstructured text.

Q: What is the first layer in a neural network?
A: Input layer

Q: Which learning method extracts features from raw, unstructured input without human labels?
A: Deep learning

Q: What do weighted connections between nodes simulate in the human brain?
A: Synapses

Task 3 — Large Language Models (LLMs)

LLMs are AI models trained on massive datasets to predict and generate human-like text. Their training has three stages: pre-training on huge text corpora to capture grammar, semantics and facts; fine-tuning with domain-specific data; and RLHF (reinforcement learning from human feedback) to make responses safer and better aligned.

Q: What AI model enabled advancements in ChatGPT?
A: Large Language Models

Q: What is the first training stage for LLMs?
A: Pre-training

Transformers revolutionized NLP with the “Attention Is All You Need” paper (2017). Their key innovation is the attention mechanism, which assigns importance (weights) to words in context; unlike RNNs, they process input in parallel, improving speed and scalability.

Q: What neural network powers modern LLMs?
A: Transformer

Task 4 — AI Security Threats

Common vulnerabilities in AI models:

  • Prompt injection: manipulating the model's instructions to bypass its restrictions.
  • Data poisoning: injecting malicious or biased data into the training set.
  • Model theft (extraction): reconstructing a proprietary model by repeatedly querying its API.
  • Privacy leakage: extracting sensitive information from the model's outputs.
  • Model drift: a drop in performance when real-world data diverges from the training data.
Further reading (independently verifiable): most of these map onto the OWASP Top 10 for LLM Applications — prompt injection is LLM01:2025, data poisoning is LLM04:2025 (Data and Model Poisoning), and privacy leakage is LLM02:2025 (Sensitive Information Disclosure). Model theft had its own slot in the original 2023 list (LLM10:2023) and today is covered mainly through MITRE ATLAS's model-extraction techniques. Together, the OWASP list and MITRE ATLAS are the two reference frameworks most security teams use to assess AI/ML systems.

AI also amplifies the attacks themselves: AI-generated malware (rapid creation and detection evasion), deepfakes (fake but realistic audio and video to impersonate people) and AI-powered phishing (auto-generated, highly convincing emails).

Q: What MITRE framework guides AI-specific threat analysis?
A: ATLAS

Q: What attack clones an AI model via its API?
A: Model theft

Q: Which generative AI technique replicates a person's likeness?
A: Deepfake

Q: What social engineering attack is harder to detect due to AI?
A: Phishing

Task 5 — Defensive AI

Applications of AI in defense:

  • Analytical enhancement: intrusion detection, anomaly spotting and log analysis.
  • Predictive automation: proactively classifying and blocking phishing and malware.
  • Summarization & triage: AI-assisted report generation for faster decisions.
  • Threat-hunting assistance: generating hypotheses about hidden threats.

Q: According to IBM, AI helps identify and contain breaches how many days faster?
A: 108 days

Q: Which task benefits from AI-driven imaginative scenario generation?
A: Threat hunting

Q: Explainability tools like SHAP and LIME assist with what?
A: Model monitoring

Secure AI practices: enforce access controls (RBAC and MFA), encrypt data by treating all training and testing datasets as sensitive, follow standards such as ISO/IEC 27090 and the MITRE ATLAS guidelines, and continuously monitor for anomalies, drift and adversarial manipulation.

Task 6 — Hands-on: Using the AI Assistant

The practical part asks the room's AI assistant to perform several analyst tasks.

Log analysis. Prompt: “Explain a failed SSH login from a log entry.” — the assistant explains the event context, the user that attempted to authenticate, the IP and the reason for the failure.

Phishing detection. Prompt: “Identify red flags in a suspicious email.” — common flags: suspicious or shortened URLs, urgent language and spoofed sender addresses.

Threat-hunting scenarios. Prompt: “Suggest three realistic corporate network hunting scenarios.” — for example: unusual outbound traffic to rare domains, multiple failed logins from external IPs, or privilege-escalation attempts on servers.

Regex generation. Prompt: “Write a regex for failed SSH login lines.”

^\w{3}\s+\d+\s\d{2}:\d{2}:\d{2}\s\S+\ssshd\[\d+\]:\sFailed password for .* from \d{1,3}(?:\.\d{1,3}){3}\sport\s\d+\sssh2$

Flag retrieval. Prompt: “What are the values for DoH port, SYN flood timeout, and ephemeral port range size?”

ParameterValue
DoH port443
SYN flood timeout60
Ephemeral port range size16384

Flag: thm{443/60/16384}

Task 7 — Conclusion

The room highlights the double-edged nature of AI: for attackers it automates phishing, malware generation and deepfakes; for defenders it accelerates detection, monitoring and incident response. The core lesson is that security professionals must stay ahead of evolving AI threats while responsibly leveraging AI for protection.

Key Takeaways

  • ML is a subset of AI that learns patterns from data; Deep Learning stacks many hidden layers to extract features automatically.
  • Modern LLMs rely on the Transformer architecture and its attention mechanism, and are trained in three stages: pre-training, fine-tuning and RLHF.
  • AI-specific threats include prompt injection, data poisoning, model theft, privacy leakage and model drift; MITRE ATLAS is the reference framework for analyzing them.
  • AI also amplifies classic attacks through AI-generated malware, deepfakes and more convincing phishing.
  • On defense, AI helps with log analysis, phishing detection, triage and threat hunting; it must be deployed with RBAC, MFA, encryption, standards (ISO/IEC 27090, ATLAS) and continuous monitoring.