mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-11-21 20:26:43 +00:00
Fix second round of review findings from PR #6029
Security - Check advanced_config permissions before creating a certificate on host update (proxy, redirection and 404 hosts). A refused request previously requested a Let's Encrypt certificate first, leaving an orphan certificate and using up rate limit. - Only trust X-NPM-Peer-Addr when it comes with a secret generated at container start. The admin nginx sends both headers. Any proxy host or stream forwarding to 127.0.0.1:3000 was also a loopback peer, so it could forge the header and get a fresh rate-limit bucket on every request. Without the secret (dev, or a mounted production.conf), the header is ignored. - Add a login limit per IP across all accounts (30 failed attempts a minute) alongside the per-account one. Before this, one address could spray passwords over any number of accounts. Behind a shared proxy, everyone using that proxy shares this limit. - Stop trusting X-Real-IP from loopback. It was only there for an older version of the rate limiter, and it let a stream host forwarding to a local proxy host forge the client IP and get past IP access lists. Loopback now behaves as it does on master. Correctness - Refuse to delete a certificate that hosts still use (400, with counts per host type). Their configs include its files, and a successful revoke deleted them anyway, which broke nginx -t. Otherwise the certificate is revoked and its files are removed even if the revoke fails. - Let non-admins clear a location's advanced config. Deleting the location was already allowed and has the same effect, and a location deleted and re-added at the same path arrives with an empty config, which was refused. - Clear proxy host grants (meta.proxy_host_ids) when visibility isn't "user" or proxy hosts are hidden, and drop ids of deleted hosts. Before, hidden grants came back when proxy hosts were shown again. The backend enforces this; the permissions modal also stops sending them. - 404 host and redirection host modals now wait for the current user to load, so an admin's advanced config change isn't dropped if they submit before it loads. Tests - NonAdminHosts.cy.js: refused change doesn't create a certificate, location rename and clear rules, grant clearing. - Certificates.cy.js: deleting a certificate that is in use.
This commit is contained in:
1 parent
04c1f5ae76
commit
5b7e34eb67
18 files changed
+423
-62
No files matched your search
@@ -25,7 +25,7 @@ interface Props extends InnerModalProps {
|
||||
id: number | "new";
|
||||
}
|
||||
const DeadHostModal = EasyModal.create(({ id, visible, remove }: Props) => {
|
||||
const { data: currentUser } = useUser("me");
|
||||
const { data: currentUser, isLoading: userIsLoading, error: userError } = useUser("me");
|
||||
const { data, isLoading, error } = useDeadHost(id);
|
||||
const { mutate: setDeadHost } = useSetDeadHost();
|
||||
const [errorMsg, setErrorMsg] = useState<ReactNode | null>(null);
|
||||
@@ -63,17 +63,17 @@ const DeadHostModal = EasyModal.create(({ id, visible, remove }: Props) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
{(isLoading || (error && !data)) && (
|
||||
{(isLoading || userIsLoading || ((error || userError) && (!data || !currentUser))) && (
|
||||
<Modal show={visible} onHide={remove}>
|
||||
{!isLoading && error && (
|
||||
{!isLoading && (error || userError) && (
|
||||
<Alert variant="danger" className="m-3">
|
||||
{error?.message || "Unknown error"}
|
||||
{error?.message || userError?.message || "Unknown error"}
|
||||
</Alert>
|
||||
)}
|
||||
{isLoading && <Loading noLogo />}
|
||||
{(isLoading || userIsLoading) && <Loading noLogo />}
|
||||
</Modal>
|
||||
)}
|
||||
{!isLoading && data && (
|
||||
{!isLoading && !userIsLoading && data && currentUser && (
|
||||
<FormModal
|
||||
show={visible}
|
||||
onHide={remove}
|
||||
|
||||
@@ -31,7 +31,13 @@ const PermissionsModal = EasyModal.create(({ id, visible, remove }: Props) => {
|
||||
setIsSubmitting(true);
|
||||
setErrorMsg(null);
|
||||
try {
|
||||
await setPermissions(id, values);
|
||||
// Proxy host grants only apply to "user" visibility with proxy hosts shown. Don't
|
||||
// submit stale ones; the backend clears them too.
|
||||
const grantsApply = values.visibility === "user" && values.proxyHosts !== "hidden";
|
||||
await setPermissions(id, {
|
||||
...values,
|
||||
meta: { ...values.meta, proxy_host_ids: grantsApply ? values.meta?.proxy_host_ids || [] : [] },
|
||||
});
|
||||
remove();
|
||||
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||
|
||||
@@ -27,7 +27,7 @@ interface Props extends InnerModalProps {
|
||||
id: number | "new";
|
||||
}
|
||||
const RedirectionHostModal = EasyModal.create(({ id, visible, remove }: Props) => {
|
||||
const { data: currentUser } = useUser("me");
|
||||
const { data: currentUser, isLoading: userIsLoading, error: userError } = useUser("me");
|
||||
const { data, isLoading, error } = useRedirectionHost(id);
|
||||
const { mutate: setRedirectionHost } = useSetRedirectionHost();
|
||||
const [errorMsg, setErrorMsg] = useState<ReactNode | null>(null);
|
||||
@@ -65,17 +65,17 @@ const RedirectionHostModal = EasyModal.create(({ id, visible, remove }: Props) =
|
||||
|
||||
return (
|
||||
<>
|
||||
{(isLoading || (error && !data)) && (
|
||||
{(isLoading || userIsLoading || ((error || userError) && (!data || !currentUser))) && (
|
||||
<Modal show={visible} onHide={remove}>
|
||||
{!isLoading && error && (
|
||||
{!isLoading && (error || userError) && (
|
||||
<Alert variant="danger" className="m-3">
|
||||
{error?.message || "Unknown error"}
|
||||
{error?.message || userError?.message || "Unknown error"}
|
||||
</Alert>
|
||||
)}
|
||||
{isLoading && <Loading noLogo />}
|
||||
{(isLoading || userIsLoading) && <Loading noLogo />}
|
||||
</Modal>
|
||||
)}
|
||||
{!isLoading && data && (
|
||||
{!isLoading && !userIsLoading && data && currentUser && (
|
||||
<FormModal
|
||||
show={visible}
|
||||
onHide={remove}
|
||||
|
||||
Reference in new issue
Block a user