Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fix for Stored Cross Site Scripting - huntr.dev #12

Merged
merged 2 commits into from
Apr 12, 2021

Conversation

huntr-helper
Copy link
Contributor

@thehunckerma (https://huntr.dev/users/thehunckerma) has fixed a potential Stored Cross Site Scripting vulnerability in your repository 馃敤. For more information, visit our website (https://huntr.dev/) or click the bounty URL below...

Q | A
Version Affected | *
Bug Fix | YES
Original Pull Request | 418sec#1

If you are happy with this disclosure, we would love to get a CVE assigned to the vulnerability. Feel free to credit @thehunckerma, the discloser found in the bounty URL (below) and @huntr-helper.

User Comments:

馃搳 Metadata *

Bounty URL: https://huntr.dev/bounties/2-other-digidocu/

鈿欙笍 Description *

DigiDocu is rendering the description field in the admin's users page without escaping it. A WYSIWYG editor is provided to the users for the profile description which itself has a built-in sanitizer. The user can bypass the WYSIWYG's default sanitizer by intercepting the request (using Burp Suite for instance) and insert some malicious XSS payload. Our fix is to sanitize the HTML before inserting it into the database.

馃捇 Technical Description *

We are using stevebauman's purify library which is a wrapper around ezyang's htmlpurifier which is a famous standards-compliant HTML filter library.
We replace the description input with the sanitized version before inserting it into the database

    // app/Http/Requests/UpdateProfileRequest.php
    /**
     * Extend the default getValidatorInstance method
     * so description field can be escaped
     *
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function getValidatorInstance()
    {
        $request = $this->toArray(); // extract all inputs
        if (array_key_exists('description', $request)) {
            $description = $request["description"]; // get description input
            $escaped_description = Purify::clean($description); // escape the data
            $this->merge(array('description' => $escaped_description)); // replace the old data with the new escaped one
        }
        return parent::getValidatorInstance();
    }

馃悰 Proof of Concept (PoC) *

User test is editing his profile:

image

User test intercepts the request using Burp Suite:

image

User test adds his XSS payload to the description input:

image

Admin super visits test's profile, XSS payload gets executed:

image

馃敟 Proof of Fix (PoF) *

User test is editing his profile:

image

User test intercepts the request using Burp Suite and adds his XSS payload to the description input:

image

Admin super visits test's profile, the <img/> element is rendered but the XSS payload is not executed:

image

The HTML element is sanitized:

image

馃憤 User Acceptance Testing (UAT)

There is no unit testing in this project but the feature in question (the WYSIWYG editor) is still working and the HTML is being rendered properly.

@esidate
Copy link
Contributor

esidate commented Apr 11, 2021

Hello @harish81, can you please merge this.

@harish81
Copy link
Owner

@thehunckerma Yes of course I will.

@harish81 harish81 merged commit d9f5d42 into harish81:master Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants