# GHSA-69VF-MJXW-X79J: Summary classes/Email.php's sendActivationEmail(), sendResetPasswordEmail(), and sendMagicLoginEmail() all call warnIfUntrustedHost() before building their token-bearing links via Utils::url(), a…

- Database: GitHub
- Severity: low (stated by ghsa, no CVSS score)
- Published: 2026-08-10
- Modified: 2026-08-10

## Affected versions

- getgrav/grav-plugin-login (Packagist): through 3.9.1

## Description

## Summary

classes/Email.php's sendActivationEmail(), sendResetPasswordEmail(), and
sendMagicLoginEmail() all call warnIfUntrustedHost() before building their
token-bearing links via Utils::url(), a detection mechanism added for
GHSA-46jp-rc59-w2gc (spoofable-Host-header link poisoning in this exact class).
sendInvitationEmail() builds an equally sensitive, token-bearing link the same way but
never calls warnIfUntrustedHost(). Separately, the stronger require_trusted_host
enforcement (which refuses to send rather than just logging a warning) is wired up for
only one of these four flows.

## Part 1: sendInvitationEmail() has no warning at all

    // classes/Email.php
    public static function sendInvitationEmail(Invitation $invitation, ...): void
    {
        ...
        $invitationLink = Utils::url("{$inviteRoute}/{$param_sep}{$invitation->token}", true, true);
        // no warnIfUntrustedHost() call anywhere in this function
        ...
    }

Compare with the other three:

    grep -n "function send\|warnIfUntrustedHost\|Utils::url(" classes/Email.php

    sendActivationEmail():     warnIfUntrustedHost('account activation'); then Utils::url(...)
    sendResetPasswordEmail():  warnIfUntrustedHost('password reset');     then Utils::url(...)
    sendMagicLoginEmail():     warnIfUntrustedHost('magic login');        then Utils::url(...)
    sendInvitationEmail():     Utils::url(...) with no warnIfUntrustedHost() call at all

## Part 2: require_trusted_host enforcement only covers the password-reset-request flow

    grep -rn "require_trusted_host" classes/ login.php

    classes/Controller.php:365:
        if ($config->get('plugins.login.require_trusted_host', false) && !Email::isTrustedHostConfigured()) {
            $this->grav['log']->error('login: password reset refused because require_trusted_host is enabled ...');

This is the only call site. The other two usages of isTrustedHostConfigured() found in
login.php (lines 1639, 1666) are admin dashboard notice banners, not request-blocking
enforcement. A site administrator who enables require_trusted_host, reasonably
expecting it to protect account activation, magic-login, and invitations given the
setting's name, gets protection for password reset only.

## Live, end-to-end Proof of Concept

Built a real Grav bootstrap (config, streams, locator, language), registered the real
Login and accounts services, and called the actual, unmodified sendActivationEmail(),
sendResetPasswordEmail(), sendMagicLoginEmail(), and sendInvitationEmail() functions
under an identical simulated untrusted-host condition (plugins.login.site_host and
system.custom_base_url both empty), capturing all logger output via a real Monolog
TestHandler.

poc.php:

    <?php
    define('GRAV_CLI', true);
    chdir('/path/to/grav');
    require 'vendor/autoload.php';
    require '/path/to/grav-plugin-login/vendor/autoload.php';
    spl_autoload_register(function ($class) {
        $prefix = 'Grav\\Plugin\\Login\\';
        if (str_starts_with($class, $prefix)) {
            $rel = substr($class, strlen($prefix));
            $path = '/path/to/grav-plugin-login/classes/' . str_replace('\\', '/', $rel) . '.php';
            if (file_exists($path)) require $path;
        }
    });

    use Grav\Common\Grav;
    use Grav\Common\User\DataUser\User;
    use Grav\Common\User\DataUser\UserCollection;
    use Grav\Plugin\Login\Email;
    use Grav\Plugin\Login\Invitations\Invitation;
    use Monolog\Logger;
    use Monolog\Handler\TestHandler;

    // no-op stand-in for the separate Email plugin's mail-transport class,
    // only invoked AFTER the link-construction code under test
    require __DIR__ . '/email_stub.php';

    $_SERVER['HTTP_HOST'] = 'attacker-controlled.example';
    $_SERVER['SERVER_NAME'] = 'attacker-controlled.example';
    $_SERVER['REQUEST_URI'] = '/';
    $_SERVER['SERVER_PORT'] = '80';

    Grav::resetInstance();
    $grav = Grav::instance();
    $grav['config']->init();
    $grav['config']->set('system.languages.supported', ['en']);
    $grav['config']->set('system.languages.default_lang', 'en');
    $grav['config']->set('plugins.login.site_host', '');
    $grav['config']->set('system.custom_base_url', '');
    $grav['config']->set('plugins.login.route_activate', '/activate');
    $grav['config']->set('plugins.login.route_reset', '/reset_password');
    $grav['config']->set('plugins.login.route_magic', '/magic_login');
    $grav['config']->set('plugins.login.route_magic_login', '/magic_login');
    $grav['config']->set('plugins.login.route_register', '/register');

    foreach (array_keys($grav['setup']->getStreams()) as $stream) {
        @stream_wrapper_unregister($stream);
    }
    $grav['streams'];
    $grav['uri']->init();
    $grav['config']->set('system.cache.enabled', false);
    $grav['accounts'] = new UserCollection(User::class);
    $grav['language']->init();

    $login = new \Grav\Plugin\Login\Login($grav);
    $grav['login'] = $login;
    $grav['user'] = new User([]);
    $grav['Email'] = new \Grav\Plugin\Email\Email();

    $testHandler = new TestHandler();
    $grav['log'] = new Logger('test', [$testHandler]);

    $user = $grav['accounts']->load('pocuser');
    $user->update(['username' => 'pocuser', 'email' => 'poc@example.com', 'password' => 'Password123!', 'state' => 'enabled']);
    $user->set('activation_token', 'abc123::' . (time() + 3600));

    function countWarnings(TestHandler $h, string $needle): int {
        $c = 0;
        foreach ($h->getRecords() as $r) {
            $msg = is_array($r) ? ($r['message'] ?? '') : $r->message;
            if (str_contains($msg, $needle)) $c++;
        }
        return $c;
    }

    $testHandler->clear();
    Email::sendActivationEmail($user);
    echo "sendActivationEmail: " . (countWarnings($testHandler, 'account activation') > 0 ? 'YES' : 'no') . "\n";

    $user->set('reset', 'def456::' . (time() + 3600));
    $testHandler->clear();
    Email::sendResetPasswordEmail($user);
    echo "sendResetPasswordEmail: " . (countWarnings($testHandler, 'password reset') > 0 ? 'YES' : 'no') . "\n";

    $testHandler->clear();
    Email::sendMagicLoginEmail($user, 'magictoken123');
    echo "sendMagicLoginEmail: " . (countWarnings($testHandler, 'magic login') > 0 ? 'YES' : 'no') . "\n";

    $invitation = new Invitation('invitetoken123', ['email' => 'victim@example.com', 'created_by' => 'pocuser']);
    $testHandler->clear();
    Email::sendInvitationEmail($invitation);
    echo "sendInvitationEmail: " . (count($testHandler->getRecords()) > 0 ? 'YES' : 'NO WARNING LOGGED') . "\n";

email_stub.php:

    <?php
    namespace Grav\Plugin\Email;
    class Email {
        public function send($message, &$failedRecipients = null) { return true; }
    }

Run: php poc.php

Real output:

    sendActivationEmail:     YES
    sendResetPasswordEmail:  YES
    sendMagicLoginEmail:     YES
    sendInvitationEmail:     NO WARNING LOGGED

All four functions ran to completion. The mail-transport stub is only ever invoked
after the link-construction and warnIfUntrustedHost code under test, so it has no
bearing on this result. The three functions with the protection correctly log a
warning under the vulnerable condition; sendInvitationEmail does not.

## Impact

On a site that has not configured plugins.login.site_host or system.custom_base_url,
an attacker who can influence the request's Host header (a well-documented technique,
especially behind misconfigured reverse proxies) can cause account-activation,
magic-login, and invitation links to point to an attacker-controlled domain instead of
the real site, the GHSA-46jp-rc59-w2gc class of link-poisoning attack, on three of the
four affected flows, even with require_trusted_host enabled, since that setting only
blocks the password-reset-request flow.

## Suggested fix

Add warnIfUntrustedHost('invitation') to sendInvitationEmail(), matching the other
three. Move the require_trusted_host enforcement into Email.php itself, as a shared
guard called from all four send*Email() functions, rather than duplicating a
Controller-level check for password reset only, so future email flows cannot
reintroduce this gap by omission.

## Affected component

- classes/Email.php, sendInvitationEmail()
- classes/Controller.php, require_trusted_host enforcement (password-reset-request
  flow only)

## References

- https://github.com/getgrav/grav/security/advisories/GHSA-69vf-mjxw-x79j

Page: https://cve.now/GHSA-69VF-MJXW-X79J

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
