Act nowcan affect a running system
Authenticated tunnels join a broad cryptography and database repair wave
This complete Monday edition combines the TTunnelLocal security rewrite with a broad RSA and AES-GCM correctness and performance series. It also repairs ECC validation, PostgreSQL parameter and BOOLINT handling, SQLite backup failures, timer shutdown and several parsing edge cases. Tunnel users must upgrade both peers together, while cryptographic backends deserve known-vector testing across Delphi and FPC targets.
TL;DR
- Land on build 2.4.17586 because the Monday RSA sequence received final compliance changes the next morning.
- TTunnelLocal moves to authenticated AES-GCM frames with separate receive and send keys.
- RSA serialization, reduction, key generation and PKCS#1/PSS validation receive extensive fixes and acceleration.
- AES-GCM partial-block, reset and cloned-state handling is corrected across optimized paths.
- PostgreSQL empty values and BOOLINT reads, SQLite backup failures and timer shutdown are repaired.
Upgrade advice
Do not stop at build 2.4.17580; use 2.4.17586, which completes the RSA compliance sequence. Upgrade both TTunnelLocal peers together, migrate tlmVersion1 references, and retest tunnel handshakes, RSA PKCS#1/PSS vectors, AES-GCM non-aligned streaming, ECC key rejection, PostgreSQL empty parameters and SQLite backup failures.
39 of 39 entries · 40 commits upstream
1
Critical
TTunnelLocal frames gain authenticated encryption and directional keys
TTunnelLocalMagic renames tlmVersion1 to tlmVersion1_aesctr and adds tlmVersion2. The active protocol switches frames from AES-CTR to AES-GCM, derives distinct receive and send keys from each side's handshake CRC, authenticates TTunnelSession as AAD, advances a 96-bit IV per direction and rejects identical CRCs or keys.
Security
mormot.crypt.core+1
a9f6b586+105-32
net: fixed TTunnelLocal handshake security
Impact
Encrypted tunnel frames now provide integrity as well as confidentiality and cannot reuse one key in both directions. Protocol identifiers and wire framing change, so mixed old/new endpoints are not compatible.
Migration required
Upgrade both TTunnelLocal peers together. Grep for tlmVersion1 and replace intentional legacy references with tlmVersion1_aesctr; use tlmVersion2 for the authenticated protocol.
Public API
TTunnelLocalMagic.tlmVersion1renamed — The legacy AES-CTR value is now named tlmVersion1_aesctr.TTunnelLocalMagic.tlmVersion2added — Identifies the authenticated AES-GCM tunnel protocol.
2
Critical
x86 assembly propagates carries across big-integer blocks correctly
The x86 and x64 _xasmadd/_xasmsub loops preserve carry or borrow with BT before ADC/SBB when crossing unrolled block boundaries.
Fixes
mormot.crypt.core.asmx64+1
8ea03422+10-10
crypt: fixed _xasmadd/sub x86/x64 asm carry propagation
Impact
Certain operand patterns could previously produce wrong big-integer sums or differences, potentially corrupting RSA calculations on Intel backends.
Upgrade recommended
Upgrade Intel builds and rerun RSA known-answer tests that exercise long all-one carry chains.
3
High
RSA serialization and signature checks now enforce canonical widths
TBigInt.SaveFixed adds leading-zero padding, RSA operations reject values at or above the modulus, and PKCS#1/PSS paths emit and verify exact-width encodings with stricter salt and padding checks.
Security
mormot.crypt.rsa
b4a21003+99-33
crypt: ensure fixed-width RSA serialization
Impact
Delphi/FPC RSA ciphertexts and signatures keep their required modulus width, while malformed or non-canonical signatures that were previously tolerated are rejected.
Upgrade recommended
Retest PKCS#1 v1.5 and PSS interoperability against independent implementations and check stored signature widths.
Public API
TBigInt.SaveFixedadded — Exports an exact number of big-endian bytes with leading-zero padding.
Units
4
High
AES-GCM validates streaming order and preserves pending state
TAesGcm uses PtrUInt lengths, clones pending AVX blocks, rejects AAD added after ciphertext, validates the high-level AAD call, and fixes the tunnel tag destination.
Security
mormot.crypt.core+1
36e581ed+22-21
crypt: several fixes to TAesGcm
Impact
Streaming and cloned AES-GCM contexts authenticate the intended bytes; invalid AAD ordering now fails instead of producing a misleading tag.
Upgrade recommended
Upgrade AES-GCM and tunnel users; test cloned contexts, AAD ordering and non-block-aligned messages.
5
High
ECC loaders reject malformed and wrong-kind keys
PemDerRawToEcc validates compressed public-key prefixes, while DerParse rejects zero-length or oversized ASN.1 INTEGER values; regression tests prevent public/private key interchange.
Security
mormot.crypt.ecc+1
e3133b00+19-8
crypt: fixed #652 ECC key parsing and validation
Impact
Malformed DER and a private key presented as a public key no longer pass loading on Delphi/FPC cryptographic backends.
Upgrade recommended
Upgrade ECC users and add negative tests for truncated DER, oversized integers and swapped key kinds.
6
High
Tunnel authentication failures erase plaintext and handshake secrets
TTunnelLocal clears decrypted output when GCM tag verification fails, adds a Handshake domain label to SHAKE-128 signatures, bounds-checks metadata length before pointer access and zeros receive/send keys after OpenInternal. Encryption preserves its allocated result if finalization raises.
Security
mormot.net.tunnel
beeed494+14-8
net: enhanced TTunnelLocal security
Impact
Rejected encrypted frames no longer leave unauthenticated plaintext in memory, and handshake signatures are separated from other SHAKE-128 uses. These are direct hardening follow-ups to the new protocol.
Upgrade recommended
Use this hardening commit or later and verify that a modified GCM tag terminates the tunnel without exposing plaintext.
Units
7
High
Tunnel metadata is size-checked before parsing and then erased
TTunnelLocal.OpenInternal checks that the remote frame still contains SizeOf(loc) bytes before extracting JSON metadata. After InitJsonInPlace consumes the buffer, FillZero(info) erases the decrypted metadata copy.
Security
mormot.net.tunnel
c08ef0d6+6-7
net: minor TTunnelLocal handshake refactoring
Impact
Malformed handshakes fail before metadata parsing, and sensitive tunnel information spends less time in process memory. No application API changes.
Upgrade recommended
Take this follow-up with the tunnel protocol rewrite and test rejection of truncated metadata frames.
Units
8
High
RSA prime rounds and PKCS padding checks are corrected
FipsMinIterations compares full bit counts, PKCS#1 unpadding now accepts any padding length of at least eight bytes, and PSS verification requires a signature exactly as wide as the modulus.
Security
mormot.crypt.rsa
c21e6cfa+6-6
crypt: several RSA fixes
Impact
RSA primality assurance and standards-compliant padding acceptance are corrected; malformed PSS lengths are rejected consistently.
Upgrade recommended
Upgrade RSA users and rerun padding, signature and generated-prime tests.
Units
9
High
Tunnel handshake metadata cannot underflow its frame pointer
TTunnelLocal.OpenInternal subtracts the advertised JSON metadata length from the remaining frame length, rejects negative results and only then builds the RawByteString view. The previous code formed the pointer before validating the subtraction.
Security
mormot.net.tunnel
c7e0e055+6-4
net: hardened TTunnel handshake
Impact
A malformed remote handshake can no longer make metadata parsing address bytes before the received frame. Tunnel peers fail with ETunnel instead.
Upgrade recommended
Upgrade both tunnel peers and include undersized and oversized JSON metadata lengths in handshake tests.
Units
10
High
Environment variables preserve empty values and restore absence
Environment caching gains an explicit initialized flag, SetSystemEnv always writes through, and ResetSystemEnv restores the cached value or unsets a name that was originally absent on Windows and POSIX.
Fixes
mormot.core.os+3
4fc7e59a+90-43
core: fixed #651 environment variables functions
Impact
An existing empty environment value is no longer mistaken for a missing cache, and temporary variables can be restored to their original absent state consistently.
Upgrade recommended
Retest SetSystemEnv and ResetSystemEnv with missing, empty and non-empty variables on Windows and POSIX.
Public API
SetSystemEnvbehaviour-changed — Always writes the requested value, including an empty string.ResetSystemEnvbehaviour-changed — Unsets variables that were absent when the cache was populated.
11
High
OpenSSL GCM preserves its IV while processing associated data
TAesOsl.UpdEvp gains an optional KeepIV argument. TAesGcmOsl passes it for payload and AAD updates so EVP_CIPHER_CTX_iv is not copied back into Owner.IV during a GCM round, and zero-length AAD calls are skipped.
Fixes
mormot.crypt.openssl
c9ed0cb9+14-19
crypt: fixed TAesGcmOsl with AEAD associated information
Impact
TAesGcmOsl can now authenticate associated information correctly instead of corrupting its IV state. OpenSSL-backed AEAD output should match the framework's pure implementation for the same vectors.
Upgrade recommended
Upgrade any TAesGcmOsl use with AesGcmAad and rerun known-answer tests for ciphertext and tags.
Public API
TAesOsl.UpdEvpsignature-changed — Adds the optional KeepIV boolean parameter with a false default.
Units
12
High
LDAP URI parsing distinguishes defaults from custom ports
TLdapClient URI parsing maps an absent no-scheme port to LDAP_PORT, preserves explicit ports and enables TLS when the effective port is LDAPS_PORT.
Fixes
mormot.net.ldap
c46549d6+21-7
net: fixed #653 LDAP port parsing
Impact
LDAP endpoints no longer accidentally inherit HTTP port 80 from generic URI parsing, and custom port selections remain effective.
Upgrade recommended
Verify host-only, ldap://, ldaps:// and explicit-port connection strings.
Units
13
High
Binary-cookie destruction releases managed context state
TBinaryCookieGenerator.Destroy replaces FillCharFast on fContext with FillZeroRtti(TypeInfo(TBinaryCookieContext), fContext). The regression test invalidates a generated cookie, validates the empty state and then destroys the generator.
Fixes
mormot.crypt.secure
69b16d3f+13-3
crypt: fixed #650 binary cookie generator memory leak
Impact
Managed fields inside TBinaryCookieContext are finalized before the anti-forensic zeroing, preventing memory retained when a generator is destroyed after cookie invalidation.
Upgrade recommended
Upgrade services that create and discard TBinaryCookieGenerator instances, especially after one-time cookie invalidation.
Units
14
High
Empty PostgreSQL parameters stay distinct from SQL NULL
TSqlDBPostgresStatement.BindParams points zero-length non-null strings at NULCHAR instead of passing a nil pointer to libpq.
Fixes
mormot.db.sql.postgres
9a90c009+7-3
db: fixed #658 TSqlDBPostgresStatement.BindParams with '' value
Impact
Binding '' no longer inserts SQL NULL, preventing silent data changes in PostgreSQL statements on Delphi and FPC.
Upgrade recommended
Upgrade PostgreSQL users and test inserts and updates that bind empty RawUtf8 or string values.
15
High
Timer shutdown waits the requested number of seconds
TSynBackgroundTimer.WaitUntilNotProcessing converts its timeout from seconds to milliseconds before passing it to SleepHiRes.
Fixes
mormot.core.threads
630707ac+3-3
core: fixed TSynBackgroundTimer.WaitUntilNotProcessing #660
Impact
The wait is no longer roughly one thousand times shorter than requested, reducing teardown races with active callbacks.
Upgrade recommended
Upgrade services that stop background timers under load and verify their shutdown latency.
Units
16
High
Thread-safe SQL pools destroy every allocated connection
TSqlDBConnectionPropertiesThreadSafe.Destroy iterates the actual connection array bounds instead of configuration minimum and maximum values.
Fixes
mormot.db.sql
db7c4721+3-3
db: fixed TSqlDBConnectionPropertiesThreadSafe.Destroy #657
Impact
Pool teardown avoids leaking initialized connections or indexing beyond the allocated array after configuration changes.
Upgrade recommended
Retest connection-pool reconfiguration and application shutdown under sanitizers or leak reporting.
Units
17
High
AES-GCM reset clears leftover partial-block length
TAesGcmEngine.Reset now sets state.blen to zero after an earlier operation ended with a non-complete block.
Fixes
mormot.crypt.core
e8367af5+3-2
crypt: fixed TAesGcmEngine.Reset after non-complete blocks
Impact
Reusing an AES-GCM engine no longer carries a stale byte offset into the next message and corrupts encryption or authentication.
Upgrade recommended
Upgrade reusable AES-GCM contexts and test consecutive messages with non-block-aligned lengths.
Units
18
High
Background timers mark work active before updating counters
TSynBackgroundTimer.EverySecond sets fProcessing before incrementing and invoking scheduled callbacks, closing the remaining WaitUntilNotProcessing race.
Fixes
mormot.core.threads
a0b02203+3-2
core: fix #660 part II
Impact
Shutdown code waiting for timer work no longer slips through the small window before the processing flag was set.
Upgrade recommended
Retest timer destruction while callbacks start or are already running.
Units
19
High
AVX AES-GCM accepts partial and truncated chunks
TAesGcmEngine buffers incomplete AAD and text blocks across calls, continues CTR bytes correctly, and makes AllowAvx default to true in Init.
New features
mormot.crypt.core
2d95c74a+128-27
crypt: allow partial/truncated AES-GCM encryption
Impact
AVX-capable Delphi/FPC builds can stream arbitrary chunk sizes instead of requiring complete blocks; omitted AllowAvx arguments now enable AVX.
Worth a look
Test one-byte through multi-block chunking and decide explicitly whether callers should pass AllowAvx false.
Public API
TAesGcmEngine.Initsignature-changed — AllowAvx now has a default value of true.
Units
20
Medium
Unknown command-line arguments name the correct token
TCommandLine.DetectUnknown reports the parsed fNames entry for an unknown argument rather than indexing the raw parameter list with the wrong offset.
Fixes
mormot.core.os
938a6bb1+12-3
core: fixed #654 unexpected command line argument reporting
Impact
Diagnostics identify the real unexpected option after switches and values have been parsed; argument acceptance is unchanged.
Units
21
Medium
LDAP keeps the parsed explicit port through connection setup
TLdapClient settings keep the URI-derived port when constructing the socket instead of falling back through a remaining default-port path.
Fixes
mormot.net.ldap
fa932d76+9-4
net: one leftover of #653
Impact
LDAP and LDAPS endpoints on custom ports connect to the configured service rather than the protocol default.
Upgrade recommended
Retest LDAP URIs with and without schemes on ports other than 389 and 636.
Units
22
Medium
PostgreSQL boolean integers return one for true
TSqlDBPostgresStatement.ColumnInt recognizes BOOLOID and maps the wire value 't' to 1 and other boolean text to 0.
Fixes
mormot.db.sql.postgres
c0bc6984+9-3
db: fixed #659 TSqlDBPostgresStatement.ColumnInt with BOOLINT value
Impact
Delphi/FPC code reading PostgreSQL boolean columns through ColumnInt now receives the expected numeric value.
Worth a look
Retest BOOLINT field mappings and queries that project boolean expressions as integers.
23
Medium
SQLite backup reports destination-open failures cleanly
BackupBackground catches exceptions raised while constructing the destination TSqlDatabase, releases partial state and returns false.
Fixes
mormot.db.raw.sqlite3
81dcd78a+7-3
db: fixed #655 backup destination creation failure
Impact
An unwritable or invalid backup destination no longer escapes as an unexpected constructor exception from the background backup API.
Worth a look
Test invalid paths and permission failures and ensure callers handle a false backup result.
24
Medium
Spaced __Secure- cookies are parsed under their logical name
THttpCookies.ParseServer and CookieFromHeaders call GotoNextNotSpace before checking the __Secure- prefix for each cookie pair. Tests cover a prefixed cookie following another value after a semicolon and space.
Fixes
mormot.core.text
95a8e9d0+8-2
net: fixed #649 cookie parsing
Impact
Cookie headers using the normal semicolon-space separator now expose __Secure- values under the expected unprefixed name instead of missing them.
Upgrade recommended
Upgrade HTTP code that reads __Secure- cookies from multi-cookie headers and rerun cookie lookup tests.
Units
25
Medium
AES-GCM gains a public 96-bit nonce increment helper
mormot.crypt.core adds GCM_IncIV, which increments bytes 0 through 11 of TAesBlock in big-endian order while leaving the 32-bit counter suffix untouched. GMAC_SIZE is expressed as SizeOf(THash128), and AES-GCM documentation clarifies buffer layout choices.
New features
mormot.crypt.core
54b070e6+24-3
crypt: new GCM_IncIV() wrapper function
Impact
Cryptographic callers can advance the 96-bit GCM nonce without modifying the block counter. Existing APIs and ciphertext formats are unchanged unless the new helper is adopted.
Public API
GCM_IncIVadded — Increments the 96-bit AES-GCM nonce portion of a TAesBlock.
Units
26
Medium
AArch64 receives native big-integer arithmetic for RSA
New AArch64 assembly implements add, subtract, multiply and divide primitives, with mormot.defines and TBigInt dispatch wired to use them.
Performance
mormot.core.base+3
78fb3897+518-69
crypt: new aarch64 asm primitives for RSA computing
Impact
Delphi and FPC AArch64 RSA operations can use native optimized arithmetic; correctness depends on the new backend matching Pascal vectors.
Worth a look
Run the RSA and TBigInt test vectors on every supported AArch64 operating system.
27
Medium
Barrett reduction computes only the low limbs it needs
TBigInt.MultiplyLow is added and TRsaContext.BarrettReduction uses it to avoid building high limbs that are immediately discarded.
Performance
mormot.crypt.rsa
c12db49f+182-6
crypt: optimized RSA barret reduction implementation
Impact
RSA modular reduction allocates and multiplies less data, improving signing and private-key workloads without output changes.
Worth a look
Run TBigInt aliasing and RSA known-answer tests on each word size.
Public API
TBigInt.MultiplyLowadded — Multiplies only the requested low limb count and releases operands like Multiply.
Units
28
Medium
RSA prime search skips candidates with cheaper remainder updates
TBigInt.FillPrime keeps small-prime remainders while incrementing candidates and avoids repeating full divisions for every primality attempt.
Performance
mormot.crypt.rsa
2791c66f+127-15
crypt: huge performance boost of RSA generation
Impact
RSA key generation becomes substantially faster, especially on slower Delphi/FPC targets, without changing key formats.
Worth a look
Benchmark representative key sizes and confirm generated keys with an independent validator.
Units
29
Medium
RSA reduction switches to a precomputed Barrett reciprocal
TRsaContext precomputes Barrett constants for its moduli and Reduce uses multiplication and shifts instead of repeated division.
Performance
mormot.crypt.rsa
bcdff3ac+68-7
crypt: use Barret Reduction for TRsaContext.Reduce()
Impact
RSA signing and verification spend less time in modular reduction; serialized values and APIs are unchanged.
Worth a look
Compare RSA vectors before and after the reduction change on 32-bit and 64-bit targets.
Units
30
Medium
Delphi 2010 avoids unsafe inline expansion in core paths
HASSAFEINLINE now starts at Delphi XE rather than Delphi 2010. Several string, lock, HTTP and ORM methods use HASSAFEINLINE so Delphi 2010 compiles them out of line while newer Delphi and FPC keep their existing inline paths.
Compiler & platform
mormot.core.base+4
86119552+15-16
core: circumvent Delphi 2010 inlining bug
Impact
Delphi 2010 builds avoid a compiler inlining defect in frequently used routines. Other supported compilers retain the same behavior and APIs.
Upgrade recommended
Rebuild Delphi 2010 targets and exercise string conversion, locking, HTTP compression and ORM JSON paths.
31
Medium
Delphi Intel builds use assembly cryptographic paths again
mormot.defines restores ASMINTELARM64 selection for Delphi x86 and x64 targets so the intended optimized primitives are compiled.
Compiler & platform
mormot.defines
b6fd1b2e+4-2
crypt: restore asm for Delphi Intel targets
Impact
Delphi Win32/Win64 cryptographic code regains assembly performance; FPC and non-Intel behavior is unchanged.
Worth a look
Rebuild Delphi Intel targets and run cryptographic vectors on both Win32 and Win64.
Units
32
Low
RSA modular powers start using a sliding window
TRsaContext.ModPower introduces a three-bit sliding window with precomputed odd powers, replacing the bit-by-bit multiply loop.
Performance
mormot.crypt.rsa
9b9e71e3+51-14
crypt: 3-bit sliding window for RSA ModPower
Impact
Private-exponent RSA operations need fewer multiplications; no migration or format change is required.
Units
33
Low
Barrett reduction avoids redundant RSA work
TRsaContext reuses precomputed modulus sizes and narrows temporary values in its optimized Barrett reduction path.
Performance
mormot.crypt.rsa
bc529ee6+36-17
crypt: optimized RSA Barret Reduction
Impact
RSA modular reduction performs less allocation and copying; application code and cryptographic output remain unchanged.
Units
34
Low
Big integers gain a dedicated squaring implementation
TBigInt.Square now computes diagonal and doubled cross-products directly instead of calling Multiply on a copy.
Performance
mormot.crypt.rsa
7be82719+39-4
crypt: dedicated TBigInt.Square method
Impact
RSA exponentiation performs faster squaring while preserving the TBigInt.Square contract for Delphi and FPC callers.
Public API
TBigInt.Squarebehaviour-changed — Uses a dedicated squaring algorithm instead of generic multiplication.
Units
35
Low
Pascal big-integer division by ten is tightened
TBigInt.IntDivMod10 rewrites its pure-Pascal quotient and remainder loop to reduce branches and repeated indexing.
Performance
mormot.crypt.rsa
dec4ec58+25-17
crypt: optimized TBigInt.IntDivMod10 pascal code
Impact
Decimal formatting of large integers becomes faster on backends without the assembly path; results are unchanged.
Units
36
Low
Exponent 65537 is computed with sixteen squares and one multiply
TRsaContext.ModPower recognizes exponent 65537 and executes its exact binary chain without allocating the generic sliding-window table.
Performance
mormot.crypt.rsa
d283eeda+17-2
crypt: optimized RSA for exponent=65537
Impact
RSA verification and encryption with the standard exponent get faster; behavior and public signatures do not change.
Units
37
Low
String-header access is simplified without changing behavior
mormot.core.base consistently names PStrRec variables sr and uses pointer decrement to reach string headers in EnsureRawUtf8 and FakeCodePage. TLdapClientSettings.SetTargetUri drops address normalization already handled by URI parsing.
Under the hood
mormot.core.base+1
b59d0bf0+51-46
core: some refactoring with no functional change
Impact
No intended application-code or runtime behavior changes. This is internal cleanup of string allocation and LDAP target parsing.
38
Low
Cryptographic core code is reorganized without behavior changes
mormot.crypt.core moves helper code and simplifies local declarations while preserving the same AES and hashing control flow.
Under the hood
mormot.crypt.core
4d9c5730+19-22
crypt: minor refactoring with no functional change
Impact
No impact on Delphi/FPC application code, public APIs or intended cryptographic results.
Units
39
Low
Decimal conversion code for big integers is cleaned up
TBigInt.IntDivMod10 consolidates local variables and loop structure without changing the division result or public method signature.
Under the hood
mormot.crypt.rsa
260dd9cb+9-14
crypt: minor TBigInt.IntDivMod10 refactoring/cleaning
Impact
No impact on Delphi/FPC application code; this is preparatory internal cleanup for later optimization.