Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1310 CNY

100%

CVE-2023-50164 PoC — Apache Struts: File upload component had a directory traversal vulnerability

Source
Associated Vulnerability
Title:Apache Struts: File upload component had a directory traversal vulnerability (CVE-2023-50164)
Description:An attacker can manipulate file upload params to enable paths traversal and under some circumstances this can lead to uploading a malicious file which can be used to perform Remote Code Execution. Users are recommended to upgrade to versions Struts 2.5.33 or Struts 6.3.0.2 or greater to fix this issue.
Readme
# CVE-2023-50164
## Sårbare versjoner
- Struts 2.0.0 - Struts 2.3.37 (EOL)
- Struts 2.5.0 - Struts 2.5.32
- Struts 6.0.0 - Struts 6.3.0

## Versjoner hvor sårbarheten er lukket
- Struts 2.5.33
- Struts 6.3.0.2

## Script for søk

### Windows/PowerShell
For Powershell 5.1 og nyere. Skrevet av [Kjetil Sigvartsen](https://github.com/kjetils-labs) i Norsk helsenett SF.
```powershell
[String[]]$Extensions = @('*.jar', '*.war', '*.ear')
[string]$searchString = 'struts2-core'

foreach ($Disk in (Get-CimInstance Win32_LogicalDisk)) {

    [string]$DriveLetter = $Disk.DeviceID
    [string]$Path        = "$($driveLetter)\"

    foreach ($ChildItem in (Get-ChildItem -Path $Path -Recurse -Include $Extensions -File -ErrorAction SilentlyContinue)) {
        [String]$FilePath = $ChildItem.FullName
        $Content  = Get-Content -Path $filePath -Raw
        if ($Content -like "*$searchString*") {
            Write-Output $filePath
        } #if
    } #foreach

} #foreach
```

### Windows/PowerShell Multi-threaded
For Powershell 5.1 og nyere. Skrevet av [Kjetil Sigvartsen](https://github.com/kjetils-labs) i Norsk helsenett SF.
Denne kan være en del mer CPU-intensiv, men vil være vesentlig raskere enn varianten over. Merk at `C:\Windows` er også filtrert ut av hastighetshensyn.
Hvis mer detaljert output er ønskelig, legg inn følgende på toppen av scriptet:

```powershell
$VerbosePreference = 'Continue'
```
Koden er forøvrig som følger:

```powershell
[String[]]$Extensions = @('*.jar', '*.war', '*.ear')
[string]$searchString = 'struts2-core'
[string[]]$Exceptions = @('C:\Windows')

foreach ($Disk in (Get-CimInstance Win32_LogicalDisk)) {

    [string]$DriveLetter = $Disk.DeviceID
    [string]$Path        = "$($driveLetter)\"

    Write-Verbose -Message "Working on $Path"

    try {
        [System.IO.DirectoryInfo[]]$Folders = Get-ChildItem -Path $Path -Directory -ErrorAction Stop
    } #try
    catch {
        Write-Verbose -Message "Unable to get child folders in disk $Path"
        continue
    } #catch

    [System.Management.Automation.Job[]]$Jobs = $Null
    [System.Management.Automation.Job[]]$Jobs = foreach ($Folder in $Folders) {
        [string]$JobName = $Path + $Folder.Name

        if ($Exceptions -contains $JobName) {
            Write-Verbose -Message "Skipping $JobName, in exception list"
            continue
        } #if

        Write-Verbose -Message "Starting jobs for $JobName"

        Start-Job -Name $JobName -ScriptBlock {
            Return (Get-ChildItem -Path $Using:JobName -Recurse -Include $Using:Extensions -File -ErrorAction SilentlyContinue)
        } #Start-Job
    } #Foreach


    [System.Object[]]$JobResults = $Null
    [System.Object[]]$JobResults = Receive-Job -Job $Jobs -AutoRemoveJob -Wait -ErrorAction Stop

    [System.Management.Automation.Job[]]$RemainingJobs = $Null
    [System.Management.Automation.Job[]]$RemainingJobs = get-Job -Name "$Path*" -ErrorAction Stop

    if ($RemainingJobs) {
        Write-Verbose -Message "$($RemainingJobs.count) jobs remaining"
    } #if


    foreach ($ChildItem in $JobResults) {
        [String]$FilePath = $ChildItem.FullName
        [string]$Content  = Get-Content -Path $filePath -Raw
        if ($Content -like "*$searchString*" -or $FilePath -like "*$searchString*") {
            Write-Output $filePath
        } #if
    } #foreach

} #foreach
```


### Linux/Bash
```bash
sudo find / -type f \( -iname "*.jar" -o -iname "*.war" -o -iname "*.ear" \) -exec grep -Fl "struts2-core" {} 2>/dev/null \;
```

## Tolking av resultater
Scriptene vil liste ut filer som er, eller inneholder, struts2 core biblioteket. Et par eksempler på dette:

`/sti/til/mappe/struts2-core-6.3.0.2.jar` - her ligger struts2 core biblioteket direkte på filsystemet, og versjonen er `6.3.0.2`, hvor sårbarheten er lukket.

`/sti/til/mappe/apps/struts2-showcase-6.3.0.2.war` - her ligger struts 2 core biblioteket inni .war-filen, hvor innholdet må listes ut for å se hvilken versjon av Struts2 som er lagt inn:

### Linux/Bash
```bash
$ unzip -l /sti/til/mappe/apps/struts2-showcase-6.3.0.2.war | fgrep struts2-core
  1519992  2023-12-05 05:58   WEB-INF/lib/struts2-core-6.3.0.2.jar
```

### Windows/PowerShell:
For Powershell 5.1 og nyere. Skrevet av [Kjetil Sigvartsen](https://github.com/kjetils-labs) i Norsk helsenett SF.
```powershell
[string[]]$ZipFiles = @(
	'C:\sti\til\mappe\apps\struts2-showcase-6.3.0.2.war'
)

Add-Type -AssemblyName System.IO.Compression.FileSystem

foreach ($ZipFile in $ZipFiles) {
	foreach ($Entry in ([System.IO.Compression.ZipFile]::OpenRead($zipFile).Entries)) {
		if ($Entry.FullName -like "*struts2-core*") {
			Write-Output $Entry.FullName
		} #if
	} #foreach
} #foreach
```
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →