mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-12-02 13:32:43 -05:00
* Add SSRF mitigations using `filter_var` and `CURLOPT_RESOLVE` The idea is to prevent FreshRSS from sending any HTTP requests to internal services, except for the ones that are explicitly allowed in the config. Based on https://github.com/moodle/moodle/blob/6e82b46a480826d1a85394d9e5087f7d82d1dd52/lib/filelib.php#L3818 and https://github.com/symfony/symfony/blob/8.1/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php https://github.com/FreshRSS/simplepie/pull/76 https://github.com/FreshRSS/simplepie/pull/78 * Add allowlist setting in Web UI * make readme * Update app/i18n/fr/admin.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * make readme again * make readme * Further work Still WIP and needs testing etc. * Readd previous if check for domain combination allowlist * Turn POST to GET after redirect * Improve * Update config.default.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * make readme * Skip SSRF check if `CURLOPT_PROXY` is set * make readme * Fix `!empty()` mistake * Respect max redirects feed option when fetching with `httpGet()` * Respect max redirects during SimplePie fetching + fix bypass bypass fix: `CURLOPT_FOLLOWLOCATION` was moved below so that emulated redirects are enforced. * Avoid FreshRSS and Minz code in SimplePie https://github.com/FreshRSS/FreshRSS/pull/8400#discussion_r2935375980 * Corrected hook code * phpdoc wrong return type * Add CIDR support in allowlist * Implement simple DNS caching * Suppress `dns_get_record()` warnings * A bit of proof-reading * Minor typo * Fix proxy logic * Fix HTTP POST redirect logic * Proofread checkCIDR Add fixes for several situations * Remove credentials from URL in logs * Ensure `CURLOPT_FOLLOWLOCATION` is `false` by setting it at the end * Fix codesniffer long line * Fix potential bypass due to wrong return value If there were no records returned by `dns_get_record()`, no overrides to `CURLOPT_RESOLVE` would get passed, and a potential bypass could occur, when cURL would try to resolve the domain by itself. * Put the URL at the end in logs * Add documentation and environment variable support * make readme * Fix wrong behavior in case of IP * Fix duplicate selector in CSS * Minor type check change * i18n fr, en * Minor type check change * Fix whitespace i18n fr * make fix-all * Fix `$ips_ok` not being returned after domain records were cached * make readme * PHPStan fix * make readme * Minor syntax in SimplePie * Only return `null` if no allowed IPs were found * Add wildcard *, help message * Consistent docs with help message * i18n: pl * SimplePie compatibility PHP 7.2 * make fix-all * Sync SimplePie * https://github.com/FreshRSS/simplepie/pull/76 * 💥 Breaking change in the Changelog * Document `INTERNAL_HOST_ALLOWLIST` in Docker docs * Remove `Cookie` and `Authorization` headers in `httpGet()` during cross-origin redirect * Minor whitespace And same comment convention than below * Remove authentication headers and change POST to GET on redirect in SimplePie * Remove .local in Docker example * Fill in default ports when comparing URL origins * Remove .local from other places than the Docker example * Rewrite WebSub subscribe to use `httpGet()` * make fix-all * Also unset `CURLOPT_USERPWD` during redirects * phpcs fix * Always unset `CURLOPT_FOLLOWLOCATION` * Bump SimplePie https://github.com/FreshRSS/simplepie/pull/78 * Update logic for CURLOPT_FOLLOWLOCATION * Fix PHPStan * Changelog fix security section * Update most common RSS Bridge case https://hub.docker.com/r/rssbridge/rss-bridge * Replace misleading 127.0.0.1:8080 example for Docker This does not make sense for a Docker container --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
169 lines
7.9 KiB
PHTML
169 lines
7.9 KiB
PHTML
<?php
|
|
declare(strict_types=1);
|
|
/** @var FreshRSS_View $this */
|
|
$this->partial('aside_configure');
|
|
?>
|
|
<main class="post">
|
|
<h1><?= _t('admin.system') ?></h1>
|
|
|
|
<form method="post" action="<?= _url('configure', 'system') ?>" data-auto-leave-validation="1">
|
|
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="instance-name"><?= _t('admin.system.instance-name') ?></label>
|
|
<div class="group-controls">
|
|
<input type="text" id="instance-name" name="instance-name" value="<?= FreshRSS_Context::systemConf()->title ?>" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="base-url"><?= _t('admin.system.base-url') ?></label>
|
|
<div class="group-controls">
|
|
<input type="text" id="base-url" name="base-url" value="<?= FreshRSS_Context::systemConf()->base_url ?>" readonly="readonly" />
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.base-url.recommendation', dirname(Minz_Request::guessBaseUrl())) ?></p>
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.sensitive-parameter') ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="websub"><?= _t('sub.feed.websub') ?></label>
|
|
<div class="group-controls">
|
|
<input type="checkbox" id="websub" name="websub" disabled="disabled" <?=
|
|
FreshRSS_Context::systemConf()->pubsubhubbub_enabled && Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) ? 'checked="checked"' : '' ?> />
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.websub.help') ?></p>
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.sensitive-parameter') ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="auto-update-url"><?= _t('admin.system.auto-update-url') ?></label>
|
|
<div class="group-controls">
|
|
<input type="text" id="auto-update-url" name="auto-update-url" disabled="disabled" value="<?= FreshRSS_Context::systemConf()->auto_update_url ?>" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="max-feeds"><?= _t('admin.system.max-feeds') ?></label>
|
|
<div class="group-controls">
|
|
<input type="number" id="max-feeds" name="max-feeds" value="<?= FreshRSS_Context::systemConf()->limits['max_feeds'] ?>" min="1" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="max-categories"><?= _t('admin.system.max-categories') ?></label>
|
|
<div class="group-controls">
|
|
<input type="number" id="max-categories" name="max-categories" value="<?= FreshRSS_Context::systemConf()->limits['max_categories'] ?>" min="1" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="cookie-duration"><?= _t('admin.system.cookie-duration.number') ?></label>
|
|
<div class="group-controls">
|
|
<input type="number" id="cookie-duration" name="cookie-duration" value="<?= FreshRSS_Context::systemConf()->limits['cookie_duration'] ?>" min="0" />
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.cookie-duration.help') ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$internal_host_allowlist = getenv('INTERNAL_HOST_ALLOWLIST');
|
|
if (is_string($internal_host_allowlist) && $internal_host_allowlist !== '') {
|
|
$internal_host_allowlist = Minz_Helper::htmlspecialchars_utf8(preg_split('/\s+/', $internal_host_allowlist, -1, PREG_SPLIT_NO_EMPTY));
|
|
}
|
|
$internal_host_allowlist_fromenv = true;
|
|
if (!is_array($internal_host_allowlist) || empty($internal_host_allowlist)) {
|
|
$internal_host_allowlist = FreshRSS_Context::systemConf()->internal_host_allowlist;
|
|
$internal_host_allowlist_fromenv = false;
|
|
}
|
|
?>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="internal-host-allowlist"><?= _t('admin.system.internal-host-allowlist') ?></label>
|
|
<div class="group-controls">
|
|
<textarea
|
|
<?= $internal_host_allowlist_fromenv ? '' : 'id="internal-host-allowlist"' ?>
|
|
name="internal-host-allowlist"
|
|
<?= $internal_host_allowlist_fromenv ? ' disabled="disabled"' : ''?>><?= implode("\n", $internal_host_allowlist) ?></textarea>
|
|
<?php if ($internal_host_allowlist_fromenv): ?>
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.override-by-env-var', 'INTERNAL_HOST_ALLOWLIST') ?></p>
|
|
<?php endif ?>
|
|
<div class="help"><?= _i('help') ?> <?= _t('admin.system.internal-host-allowlist.help') ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<h2><?= _t('admin.system.registration.title') ?></h2>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="max-registrations-select"><?= _t('admin.system.registration.select.label') ?></label>
|
|
<div class="group-controls">
|
|
<select class="select-input-changer" name="" data-name="max-registrations">
|
|
<option value="1" <?= FreshRSS_Context::systemConf()->limits['max_registrations'] == 1 ? 'selected = "selected"' : ''; ?> data-input-visible="false"><?= _t('admin.system.registration.select.option.noform') ?></option>
|
|
<option value="0" <?= FreshRSS_Context::systemConf()->limits['max_registrations'] == 0 ? 'selected = "selected"' : ''; ?> data-input-visible="false"><?= _t('admin.system.registration.select.option.nolimit') ?></option>
|
|
<option value="2" <?= FreshRSS_Context::systemConf()->limits['max_registrations'] > 1 ? 'selected = "selected"' : ''; ?> data-input-visible="true"><?= _t('admin.system.registration.select.option.setaccountsnumber') ?></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group" id="max-registrations-block">
|
|
<label class="group-name" for="max-registrations-input"><?= _t('admin.system.registration.number') ?></label>
|
|
<div class="group-controls">
|
|
<?php $number = count(FreshRSS_user_Controller::listUsers()); ?>
|
|
<input type="number" id="max-registrations-input" name="" value="<?= FreshRSS_Context::systemConf()->limits['max_registrations'] > 1 ? FreshRSS_Context::systemConf()->limits['max_registrations'] : $number + 1; ?>" min="2" data-number="<?= $number ?>"/>
|
|
<span id="max-registrations-status-disabled">(= <?= _t('admin.system.registration.status.disabled') ?>)</span><span id="max-registrations-status-enabled">(= <?= _t('admin.system.registration.status.enabled') ?>)</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="group-controls">
|
|
<?= ($number > 1 ? _t('admin.user.numbers', $number) : _t('admin.user.number', $number)); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name" for="closed_registration_message"><?= _t('admin.system.closed_registration_message') ?></label>
|
|
<div class="group-controls">
|
|
<textarea id="closed_registration_message" name="closed_registration_message" rows="4" cols="50"><?=
|
|
FreshRSS_Context::systemConf()->attributeString('closed_registration_message') ?:
|
|
_t('admin.system.default_closed_registration_message')
|
|
?></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="group-name"><?= _t('index.tos.title') ?></label>
|
|
<div class="group-controls">
|
|
<?php if (file_exists(TOS_FILENAME)) { ?>
|
|
<?= _t('admin.system.tos.enabled') ?>
|
|
<?php
|
|
} else { ?>
|
|
<?= _t('admin.system.tos.disabled') ?>
|
|
<p class="help"><?= _i('help') ?> <?= _t('admin.system.tos.help') ?></p>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="group-controls">
|
|
<label class="checkbox" for="force-email-validation">
|
|
<input
|
|
type="checkbox"
|
|
name="force-email-validation"
|
|
id="force-email-validation"
|
|
value="1"
|
|
<?= FreshRSS_Context::systemConf()->force_email_validation ? 'checked="checked"' : '' ?>
|
|
/>
|
|
<?= _t('admin.system.force_email_validation') ?>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group form-actions">
|
|
<div class="group-controls">
|
|
<button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
|
|
<button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</main>
|
|
|
|
<script src="../scripts/config.js?<?= @filemtime(PUBLIC_PATH . '/scripts/config.js') ?>"></script>
|