Skip to content

Verify the TLS certificate in the whois lookup - #270

Open
PM84 wants to merge 1 commit into
catalyst:MOODLE_39_STABLEfrom
bycs-lp:fix-whois-tls-peer-verification
Open

PM84 wants to merge 1 commit into
catalyst:MOODLE_39_STABLEfrom
bycs-lp:fix-whois-tls-peer-verification

Conversation

@PM84

@PM84 PM84 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Problem

The DNS check looks up the owner of public IP addresses on who.is and shows the result in the status report. The HTTPS request does not verify the server certificate, so a forged response could be displayed.

Cause

\curl from Moodle core sets CURLOPT_SSL_VERIFYPEER to 0 by default and dnscheck.php does not override it.

Fix

dnscheck.php passes CURLOPT_SSL_VERIFYPEER => 1 for the who.is request. If verification fails, the response is empty and the check falls back to the existing output without the organisation name. version.php is bumped as described in the README.

The session check in index.php also uses \curl against the site's own URL. I deliberately left it unchanged, because enforcing verification there would break setups that use a self-signed or internal CA certificate on that path.

This is a security hardening change.

Tests

  • php -l and phpcs --standard=moodle on the changed files: no findings.
  • The existing PHPUnit suite of the plugin (43 tests) passed on an earlier run of the same code (before the version.php bump); it was not run again on this branch.
  • No new unit test: the request goes to an external host and is not mockable in the current test setup. The change was not exercised against the live who.is endpoint.

Compatibility

Sites whose PHP/curl installation lacks a usable CA bundle will no longer see the organisation name in the DNS check; the check itself keeps working.

Pull request checks

  • I have checked the version numbers are correct as per the README

The DNS check fetched the whois page through the Moodle curl wrapper, which
does not verify the TLS peer by default, so a forged response could be
displayed in the status report. Enable CURLOPT_SSL_VERIFYPEER for this
request. This is a security hardening change.
@PM84
PM84 force-pushed the fix-whois-tls-peer-verification branch from 5d29ba4 to ddf9011 Compare December 2, 2026 20:07
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.

1 participant