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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent possible XSS attack vector in the input fields of the group section #1443

Merged
merged 1 commit into from
Jun 14, 2020

Conversation

PromoFaux
Copy link
Member

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • I have commented my proposed changes within the code.
  • I have tested my proposed changes, and have included unit tests where possible.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)

What does this PR aim to accomplish?:

Calls the already existing utils.escapeHtml() to make sure nothing is executed. Works independent of CSP changes

@PromoFaux PromoFaux requested a review from XhmikosR June 6, 2020 11:24
@XhmikosR
Copy link
Contributor

XhmikosR commented Jun 8, 2020

You need to include utils.js in dns_records.php before ip-address-sorting.js.

I still need to test this myself before approving.

@XhmikosR
Copy link
Contributor

XhmikosR commented Jun 8, 2020

I only tested group-domains.php and it seems to work. Someone should try the other pages just to be sure.

@XhmikosR XhmikosR added this to the v5.1 milestone Jun 8, 2020
XhmikosR
XhmikosR previously approved these changes Jun 8, 2020
@XhmikosR
Copy link
Contributor

XhmikosR commented Jun 8, 2020 via email

@PromoFaux PromoFaux marked this pull request as draft June 8, 2020 15:50
@PromoFaux PromoFaux marked this pull request as ready for review June 8, 2020 16:19
@PromoFaux PromoFaux requested a review from XhmikosR June 8, 2020 16:19
@XhmikosR
Copy link
Contributor

XhmikosR commented Jun 8, 2020

I'd like @DL6ER to confirm the database-related code. For example I see this from the PHP page:

Although this argument is technically optional, you are highly encouraged to specify the correct value for your code if you are using PHP 5.5 or earlier, or if your default_charset configuration option may be set incorrectly for the given input.

I will try the branch again tomorrow, and try to review all JS code in those files.

@PromoFaux
Copy link
Member Author

PromoFaux commented Jun 8, 2020

1c5bbc1 prevents an (unlikely, but possible) attack vector:

Given the following entry in the static lease file:

dhcp-host=AA:BB:CC:DD:EF:FF,192.168.1.1,<script>alert("hello")</script>

Before patch:

image

image

After patch script is no longer run:

image

@PromoFaux PromoFaux force-pushed the sanitise-group-input branch 2 times, most recently from f3dbc4c to 1c5bbc1 Compare June 8, 2020 22:34
@DL6ER
Copy link
Member

DL6ER commented Jun 10, 2020

@XhmikosR I cannot test anything until beginning/mid of next week. I fully trust @PromoFaux to be aware of any database-related issues that might be there. Note that it is planed to drop any SQL stuff from the web interface for Pi-hole v6.0 and to shift any list manipulations into the API (provided by FTL). This to reduce the number of places where stuff can get changed and where write-access is needed.

@PromoFaux
Copy link
Member Author

There are a couple more places I want to check before merging (see my screenshots on mattermost for more info)

@DL6ER DL6ER marked this pull request as draft June 10, 2020 14:02
…y_decode/htmlentities in PHP

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
@PromoFaux PromoFaux marked this pull request as ready for review June 13, 2020 17:53
Copy link
Member

@DL6ER DL6ER left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and found no oddities.

@PromoFaux PromoFaux merged commit d187219 into devel Jun 14, 2020
@PromoFaux PromoFaux deleted the sanitise-group-input branch June 14, 2020 22:25
@PromoFaux
Copy link
Member Author

Thanks to Dino at @telspacesystems and also @spartacvs for reporting the issues that lead to this PR

@iasdeoupxe
Copy link

CVE-2020-14971 seems got assigned for this issue:

https://blog.telspace.co.za/2020/06/pi-hole-code-injection-cve-2020-14971.html

@PromoFaux PromoFaux mentioned this pull request Jul 5, 2020
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-5-1-released/35577/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants