Sessione salvata cifrata, copiata a «Ho finito» (#36, S4)
verifica / controlli (push) Successful in 22s
verifica / prove (push) Successful in 16m46s
verifica / installatore (push) Successful in 4m43s
verifica / immagine (push) Successful in 21m2s

Il client del sito ha bisogno della sessione del browser di Febe: ora la copia
c'è, cifrata e dietro un interruttore, senza cambiare nulla di predefinito.

- Opzione «raccolta» (pagine predefinita, richieste): solo con «richieste» e
  almeno un'operazione configurata si costruiscono sessione salvata, client del
  sito e copia. Con Instagram nulla cambia: le dieci operazioni restano non
  configurate (mancano __spin_*, __req, __s, __dyn, __csr e altri).
- Cookie con dominio, percorso, solo-host, Secure, HttpOnly e scadenza, mandati
  solo dove il browser li manderebbe (RFC 6265).
- Sezione «page» del catalogo: dove la pagina tiene ogni valore; nuovi campi rev,
  hs, hsi, dpr, ccg, comet_req, entry_nonce. Il caricatore rifiuta
  un'operazione configurata con un valore di sessione senza fonte nella pagina.
- Dati/sessione/sessione.json: DPAPI su Windows, AES-256-GCM in Docker (chiave
  da FEBE_CHIAVE_SESSIONE o chiave.bin), scrittura atomica, file illeggibile =
  nessuna sessione. «Scollega» la cancella; chiave.bin resta.
- Copia a «Ho finito» con Network.getCookies e una sola Runtime.evaluate in sola
  lettura, solo da una pagina del sito e finché dura il permesso di guida.
- FEBE_PASSWORD e FEBE_CHIAVE_SESSIONE non passano a Chromium, Xvfb, ffmpeg.
- Sito di prova: csrftoken, cookie limitato a /api/, registro di moduli suo.
- Revisione su tre lenti: 11 punti confermati, tutti corretti.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-17 16:43:43 +01:00
1 parent 3046b2da47
commit c87768766c
69 files changed
+5936 -415

No files matched your search

@@ -0,0 +1,70 @@
namespace Febe.Core.Security;
/// <summary>
/// Encrypts the saved session before it touches the disk (issue #36, S4, spec §13.2): DPAPI for the current user on
/// Windows (in Febe.Desktop, the only project with <c>ProtectedData</c> and no package), AES-256-GCM with a key of its
/// own in Docker (<see cref="AesGcmSessionProtector"/>). The text it protects never reaches a log or an exception.
/// </summary>
public interface ISessionProtector
{
/// <summary>The scheme, for the log: <c>dpapi</c> or <c>aes-gcm</c>.</summary>
string Scheme { get; }
/// <summary>The encrypted form of <paramref name="plain"/>, starting with <see cref="SessionBlob"/>'s header.</summary>
byte[] Protect(ReadOnlySpan<byte> plain);
/// <summary>The plain text of <paramref name="blob"/>.</summary>
/// <exception cref="SessionUnreadableException">Another key or user, a damaged file, another scheme or format.</exception>
byte[] Unprotect(ReadOnlySpan<byte> blob);
}
/// <summary>
/// The header every protected session starts with: <c>FEBS</c>, the format version, the scheme. It says only what the
/// file is, never what it holds; the AES scheme authenticates it.
/// </summary>
public static class SessionBlob
{
/// <summary>The scheme byte of DPAPI.</summary>
public const byte Dpapi = 1;
/// <summary>The scheme byte of AES-256-GCM.</summary>
public const byte AesGcm = 2;
/// <summary>The format version.</summary>
public const byte Version = 1;
/// <summary>The length of the header.</summary>
public const int HeaderLength = 6;
/// <summary>The header for <paramref name="scheme"/>.</summary>
public static byte[] Header(byte scheme) => [(byte)'F', (byte)'E', (byte)'B', (byte)'S', Version, scheme];
/// <summary>True when <paramref name="blob"/> starts with the header of <paramref name="scheme"/>.</summary>
public static bool HasHeader(ReadOnlySpan<byte> blob, byte scheme) =>
blob.Length >= HeaderLength && blob[..HeaderLength].SequenceEqual(Header(scheme));
}
/// <summary>
/// The saved session cannot be read: another key or user, a damaged file, another format. Its message is fixed and
/// carries no inner text: Febe treats it as no session and asks for a new login.
/// </summary>
public sealed class SessionUnreadableException : Exception
{
/// <summary>The fixed message.</summary>
public const string Text = "La sessione salvata non si legge (cifratura o formato): serve un nuovo accesso.";
public SessionUnreadableException()
: base(Text)
{
}
public SessionUnreadableException(string message)
: base(message)
{
}
public SessionUnreadableException(string message, Exception innerException)
: base(message, innerException)
{
}
}