Support » Plugin: article2pdf » PDF download path improperly sanitised

  • When visiting the PDF download link which the original PDF generation
    link redirects to, the file path is constructed from a combination of
    fixed strings and the strings provided via the query string of the
    download URL. The download URL has the form
    where xxx is a base64 encoded absolute string, xxx is a short hex hash
    and zzz is the base64 encoded URL title slug of the post the PDF was
    generated from. While the plugin attempts to sanitise these input
    parameters to not allow path traversal, this sanitisation is
    insufficient and can be fully or partially circumvented depending on
    the PHP version the WordPress instance is running on.

    In the case of PHP version <5.3 it is possible to read any file the
    user the plugin is executed under has read access to by just encoding
    the full file path in the parameter “d” and terminating that string
    with a null-byte. The parameter “p” must not be empty but can contain
    any value. The parameter “r” may be empty but its value is of no
    significance. If the user that the script is executed as has write
    access to the file or the directory it is stored in, the file will be
    deleted after it has been downloaded. If the user has no write access,
    an error message may be shown at the end of the file contents
    offered which discloses the WordPress instance’s install directory on
    the server.

    In the case of PHP version >=5.3, null-termination will no longer cut
    off the string. As the generated file name ends with a fixed string
    “.pdf”, only files with that file ending can be read. The parameter “d”
    may be any directory on the server. The parameter “p” needs to contain
    8 backspace characters to delete a prepended fixed string from the file
    name while the parameter “r” must contain exactly one backspace. The
    actual file name (without the “.pdf”) can then be appended to the
    backspaces in either parameter “p” or parameter “r”. It is also
    possible to have “p” contain one random character and then have 10
    backspace characters followed by the actual file name (again,
    without the “.pdf”) stored in parameter “r”.

  • The topic ‘PDF download path improperly sanitised’ is closed to new replies.