Close what the security review found

A session alone could change the password, switch the second factor on or
off, send the key of the language model to another address and remove the
rules that stop purchases. Each now needs the password and the code, with
one limit on wrong attempts that a restart of the services does not clear,
and the other sessions end when the password or the factor changes.

Requests to the brokers pass a list of allowed calls, never follow a
redirect with a key and are signed by one client only. Pages are closed by
default, nothing is cached, requests are limited to 1 MB, secrets are
masked in logs and notifications, exported tables cannot run as formulas,
archives carry no sessions and the container refuses to run as root.

refs #68

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 19:11:11 +01:00
1 parent 4897594b87
commit 4d92a39fef
35 files changed
+907 -118

No files matched your search

@@ -333,7 +333,7 @@
<AntiforgeryToken />
<input type="hidden" name="ritorno" value="/impostazioni#notizie" />
<label for="@rule.Key">@definition.Label</label>
<select id="@rule.Key" name="valore" disabled="@(rule.ReadOnly || Shell.IsDemo)" data-autosubmit>
<select id="@rule.Key" name="valore" disabled="@(rule.ReadOnly || Shell.IsDemo)" data-autosubmit="@(_anyLive && rule.Value != "off" ? null : "")">
<option value="on" selected="@(rule.Value != "off")">Accesa</option>
<option value="off" selected="@(rule.Value == "off")">Spenta</option>
</select>
@@ -341,6 +341,14 @@
{
<span class="hint">Fissato da @rule.Source: si cambia lì.</span>
}
else if (!Shell.IsDemo && _anyLive && rule.Value != "off")
{
<p class="note">Una strategia usa soldi veri: per spegnere la regola servono la frase e la password.</p>
<label>Scrivi: <code>@StageBook.RaisePhrase</code><input name="frase" autocomplete="off" /></label>
<label>Password<input name="password" type="password" autocomplete="current-password" /></label>
<label>Codice a sei cifre (se attivo)<input name="codice" inputmode="numeric" autocomplete="one-time-code" /></label>
<button class="btn btn-small" type="submit">Salva</button>
}
else if (!Shell.IsDemo)
{
<noscript><button class="btn btn-small" type="submit">Salva</button></noscript>
@@ -499,6 +507,8 @@
</ol>
<form method="post" action="/azioni/due-fattori/attiva" class="form">
<AntiforgeryToken />
<label for="password-nuovo-2fa">Password</label>
<input id="password-nuovo-2fa" name="password" type="password" autocomplete="current-password" required />
<label for="codice">Codice</label>
<input id="codice" name="codice" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}" maxlength="6" required />
<button class="btn" type="submit">Attiva il secondo fattore</button>
@@ -685,6 +695,8 @@
private string? ErrorText => Errore switch
{
"codice" => "Il codice non è giusto. Controlla l'ora del telefono e riprova con il codice che vedi adesso.",
"password-o-codice" => "La password o il codice non sono giusti. Controlla l'ora del telefono e riprova con il codice che vedi adesso.",
"gia-attivo" => "Il secondo fattore è già attivo: per cambiarlo prima disattivalo.",
"segreto" => "La chiave è scaduta: ricarica la pagina e aggiungi di nuovo Anubis nell'app.",
"salvataggio" => "Il salvataggio non è riuscito. Controlla lo spazio libero nella cartella dei dati.",
"impostazione" => "Questa impostazione non si può cambiare così.",
@@ -730,6 +742,7 @@
var value = _llm.GetValueOrDefault(key) ?? new SettingValue(key, definition.Default, false, null);
var locked = value.ReadOnly || Shell.IsDemo;
var shown = decimals is { } d ? Format.Number(decimal.Parse(value.Value, CultureInfo.InvariantCulture), d) : value.Value;
var asksPassword = key == Anubis.News.NewsModelSettings.Address.Key || key == Anubis.News.NewsModelSettings.Provider.Key;
var provider = _llm.GetValueOrDefault(Anubis.News.NewsModelSettings.Provider.Key)?.Value ?? Anubis.News.NewsModelProviders.Anthropic;
return @<form method="post" action="/azioni/impostazioni/@key" class="form-inline">
<AntiforgeryToken />
@@ -737,26 +750,32 @@
<label for="@id">@label</label>
@if (definition.Allowed is { } choices)
{
<select id="@id" name="valore" disabled="@locked" data-autosubmit>
<select id="@id" name="valore" disabled="@locked">
@foreach (var choice in choices)
{
<option value="@choice" selected="@(choice == value.Value)">@ProviderName(choice)</option>
}
</select>
@if (!locked)
{
<noscript><button class="btn btn-small" type="submit">Salva</button></noscript>
}
}
else
{
<input id="@id" name="valore" inputmode="@(decimals is null ? "text" : "decimal")" autocomplete="off" spellcheck="false" value="@shown"
placeholder="@(key == Anubis.News.NewsModelSettings.Address.Key ? Anubis.News.NewsModelProviders.DefaultAddress(provider).ToString() : null)"
readonly="@locked" required="@(key != Anubis.News.NewsModelSettings.Address.Key)" />
@if (!locked)
}
@if (!locked)
{
@if (asksPassword)
{
<button class="btn btn-small" type="submit">Salva</button>
<label for="@(id + "-password")">Password</label>
<input id="@(id + "-password")" name="password" type="password" autocomplete="current-password" required />
@if (_hasSecondFactor)
{
<label for="@(id + "-codice")">Codice</label>
<input id="@(id + "-codice")" name="codice" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9]{6}" maxlength="6" required />
}
}
<button class="btn btn-small" type="submit">Salva</button>
}
@if (value.ReadOnly)
{