Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
cve-2023-38408 — An in-depth analysis of CVE 2023 38408, a critical OpenSSH vulnerability, including technical background, exploitation in controlled environments, and mitigation strategies. | Kitploit
Tools/GitHubGitHub/adel2411/cve-2023-38408
Vulnerability AnalysisExploitationPenetration TestingPapers & ResearchLearning & EducationRed Teaming
GitHubadel2411/cve-2023-38408

cve-2023-38408

An in-depth analysis of CVE 2023 38408, a critical OpenSSH vulnerability, including technical background, exploitation in controlled environments, and mitigation strategies.

View Repository
551 year agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2023-38408: Understanding and Simulating a Real-World SSH-Agent Vulnerability

Table of Contents

  1. Introduction
  2. Background Concepts
  3. The CVE-2023-38408 Vulnerability
  4. Practical Simulation and Testing
  5. Technical Analysis
  6. Fix and Mitigation
  7. Conclusion

1. Introduction

Purpose of the Report

The purpose of this report is to analyze CVE-2023-38408, a critical real-world vulnerability discovered in OpenSSH, through both theoretical understanding and practical simulation. The report explains the technical foundations of the vulnerability, demonstrates how it can be exploited in controlled environments, and examines implemented mitigation measures.

Importance of Analyzing Real-World Vulnerabilities

Understanding real-world security vulnerabilities through hands-on simulation not only helps protect systems but also strengthens developers' and system administrators' awareness of potential attack vectors. Analyzing such vulnerabilities bridges the gap between theory and practical security implementation.

What is CVE-2023-38408 and Why It Matters

CVE-2023-38408 is a vulnerability that affects ssh-agent in OpenSSH when PKCS#11 support is enabled. It allows remote code execution on a client machine if the user connects to a compromised server with agent forwarding enabled (ssh -A). This vulnerability has severe implications for any system relying on OpenSSH for secure authentication.

CVE DetailsInformation
CVE IDCVE-2023-38408
CVSS Score9.8 (Critical)
Affected VersionsOpenSSH < 9.3p2
Attack VectorNetwork
Privileges RequiredNone
User InteractionRequired
ImpactComplete system compromise

2. Background Concepts

2.1 SSH Overview

SSH (Secure Shell) is a cryptographic network protocol used for secure communication over unsecured networks. It provides encrypted channels for remote login, command execution, file transfer, and more.

graph LR
    A[SSH Client] -->|Encrypted Connection| B[SSH Server]
    A -->|Authentication| C[ssh-agent]
    C -->|Private Keys| D[Key Store]
    B -->|Agent Forwarding| E[Remote ssh-agent Proxy]

2.2 What is ssh-agent

ssh-agent is a background process that stores your decrypted private SSH keys in memory, allowing you to use them without re-entering passphrases every time you connect to a remote system.

Agent Forwarding (ssh -A)

Agent forwarding allows a remote system to access your local ssh-agent through a Unix domain socket. This is useful for chaining SSH connections but introduces significant security risks if the remote machine is compromised.

sequenceDiagram
    participant Client as SSH Client
    participant Agent as ssh-agent
    participant Server as Remote Server
    participant Proxy as Agent Proxy

    Client->>Agent: Start agent
    Client->>Server: ssh -A user@server
    Server->>Proxy: Create proxy socket
    Note over Server,Proxy: SSH_AUTH_SOCK=/tmp/ssh-xxx/agent.xxx
    Server->>Proxy: ssh-add request
    Proxy->>Client: Forward request
    Client->>Agent: Process request
    Agent->>Client: Response
    Client->>Proxy: Forward response
    Proxy->>Server: Final response

Technically, when you use ssh -A, the SSH client sets up a Unix domain socket on the remote server that acts as a proxy to your local ssh-agent. The environment variable SSH_AUTH_SOCK is set to point to this proxy socket. Any calls made to SSH_AUTH_SOCK on the remote server are forwarded back through the SSH connection and processed by your local ssh-agent.

2.3 What is PKCS#11

PKCS#11 is a standard API for interacting with cryptographic tokens, such as smartcards, YubiKeys, or virtual hardware security modules (HSMs).

PKCS#11 FunctionPurposeRisk Level
C_Initialize()Initialize the libraryLow
C_GetSlotList()List available slotsLow
C_FindObjects()Find cryptographic objectsMedium
C_Sign()Sign dataHigh
dlopen()Load shared libraryCritical

How ssh-agent Supports PKCS#11

OpenSSH's ssh-agent supports loading PKCS#11 providers (shared .so libraries) using the command ssh-add -s /path/to/provider.so. These libraries allow the agent to interact with secure hardware or software modules to use private keys without exposing them directly.

Under the hood, when ssh-add -s is called, it performs the following:

  • The .so file is dynamically loaded into memory using dlopen().
  • The agent resolves and calls functions like C_Initialize(), C_GetSlotList(), C_FindObjects(), and C_Sign() via the PKCS#11 API.
  • The provider returns metadata and handles requests to sign authentication challenges, keeping private key material securely within the hardware token.

3. The CVE-2023-38408 Vulnerability

3.1 CVE Summary

AttributeDetails
IDCVE-2023-38408
SeverityHigh (CVSS 9.8)
TimelineDisclosed July 2023, fixed in OpenSSH 9.3p2
Affected SoftwareOpenSSH versions before 9.3p2 with PKCS#11 support
Attack ComplexityLow
Attack VectorNetwork via SSH agent forwarding

3.2 Vulnerability Mechanism

The vulnerability stems from ssh-agent loading any shared object file (.so) provided via ssh-add -s, without validating whether it was a legitimate PKCS#11 provider.

graph TD
    A[Attacker sends ssh-add -s malicious.so] --> B[Request forwarded to victim's ssh-agent]
    B --> C[ssh-agent calls dlopen on malicious.so]
    C --> D[Constructor function executes immediately]
    D --> E[Arbitrary code runs on victim machine]

3.3 Attack Flow Analysis

sequenceDiagram
    participant V as Victim
    participant A as Attacker
    participant Agent as ssh-agent
    participant Lib as Malicious .so

    V->>A: ssh -A attacker@host
    Note over V,A: Agent forwarding enabled
    A->>Agent: ssh-add -s /path/to/malicious.so
    Agent->>Lib: dlopen("/path/to/malicious.so")
    Note over Lib: Constructor executes
    Lib->>V: Malicious code runs
    Note over V: System compromised

At the lowest level, the sequence of events includes:

  1. A remote system sends a request to the forwarded agent asking it to ssh-add -s /path/to/lib.so
  2. The local ssh-agent receives this request and blindly calls dlopen("/path/to/lib.so", RTLD_NOW)
  3. If the .so file has a constructor function (__attribute__((constructor))), it executes immediately upon loading
  4. This constructor can contain arbitrary malicious code that runs on the client machine

3.4 Real Attack Scenario

Download Tool