Repository navigation
v0.2.1: tRFC/qRFC submit, EC keys for SNC, every source an observation - #65
Merged
Merged
Conversation
PSEs with ECDSA keys (P-256, P-384, P-521), as sapgenpse -a ECDSA and
current SAP systems create them, were refused ("only RSA keys are
supported"). They now load, sign the handshake, and EC server
certificates and EC-signed chains are verified.
- pse.py: an EC key object (id-ecPublicKey + curve, BIT STRING holding an
RFC 5915 ECPrivateKey) is returned as PKCS#8. New fixtures pse_ec_*
from sapgenpse, checked against its own export_p8; a DSA PSE fixture
shows other key types are refused clearly.
- secgss.py: signature ids 00000606/00000506/00000206 = ECDSA with
SHA-512/384/256. Established against CommonCryptoLib as the acceptor
with an EC key: offered exactly one id, it signed with that algorithm
and aborted for every other id it lists. AlgorithmIdentifier carries
the OID without parameters; the BIT STRING holds 00 || DER
Ecdsa-Sig-Value, as the reference client sends it. The client signs
with the first id in the server's list its key can use (RFC 6979
deterministic ECDSA via ecdsa) and now offers the ECDSA ids after the
RSA ones, in the reference client's order.
- Fixtures secgss_ec_loopback (EC/EC, plus the reference client's own
tokens) and secgss_ec_client_rsa_server (EC P-384 client, RSA server)
replay byte for byte, records included. Every combination of RSA and
EC P-256/384/521 keys on both sides completed a handshake with
CommonCryptoLib. The new AuthRequest was confirmed live: RSA logon to
S/4HANA still succeeds.
- The two older replays pin the RSA-only list they were recorded with;
the test checks that list against the recorded token. Fixtures are
unchanged.
) snc_sso="0" counted as on: the password was dropped and the logon used the SNC identity. snc_sso, snc_kerberos, ws_tls_verify, ms_use_http, strict_params and allow_restricted_logon now accept True/False, 1/0 and the NW RFC SDK strings "1"/"0"; anything else raises TypeError before a connection is opened. Changelog entries for this and the EC support.
Two comments in snc.py and one in a test named internal functions of the SAP libraries as the source of a fact. Cite the evidence the facts rest on instead: the eye-catcher seen in every captured frame (golden fixture snc_frame_headers.json) and the bare DN accepted in live snc_lib logons.
…t [ASSUMED] Comments and docs that cited "protocol analysis" or named internal functions, symbols or constants of SAP binaries now cite the capture, golden fixture or live probe behind the fact. Where none exists, the fact is labelled [ASSUMED] with what would settle it: - RFC types 31-40: only INT8 = 31 with 8 bytes was seen (A4H metadata for GET_TASK_INFO, 2026-11-12); no standard remote-enabled module on A4H uses the others. The docs had called them confirmed; the fixtures already said synthetic/[ASSUMED]. - SAP LZ4 wRFC frames, the inbound 0x5001 parameter block: no capture. - TID character set beyond hex: live TIDs are hex; a probe is blocked by issue #36 (a tRFC submit fails before the TID is checked). - PROGRAM_ID limits: a live registration probe could not read the result back. Rechecked against the captures on the way: GW_INFO (224 bytes) and GW_DONE (80 bytes) fields, with bytes 78:80 carrying the gateway's connection index rather than a fixed 0x0004; the GW_CONNECT reply carries 0x06 at [21]; TABLE parameters report type 5 in live metadata; 0x0303/0x0304/0x0305 all appear in live responses. The TID section of trfc.md now describes the observed hex form instead of an unverified encoding. tests/test_repo_hygiene.py fails if such references come back. Behaviour is unchanged. Changelog: 0.2.1.
call_transactional() sent the TID, function and queue as parameters ARFC_DEST_SHIP does not declare, so every submit was refused with "Field TID did not have a value", and the function's own parameters were never sent. The submit is now 0x0504 followed by ARFC_DEST_SHIP with two tables: STATE (ARFCRSTATE), one row per call carrying the TID, function and, for qRFC, the queue name in ARFCRESERV; and DATA (ARFCRDATA), the call serialized with the logon's header and cut into 1785-byte pieces. Both row layouts come from the server's metadata. confirm_tid() sends API_CLEAR_TID after 0x0513. Rebuilt byte for byte from captures of the reference client (tests/golden/trfc/trfc_reference.json); live, the server records each call as executed, queues qRFC calls in TRFCQIN, ignores a resubmit of the same TID and forgets it on confirm, over TCP and SNC. Table rows are now sent at the structure's padded width (end of the last field rounded up to its alignment), which matched X030L-TABLEN for all 357 flat structures of a live sample. Queue names are limited to 24 characters, the server's queue column, which silently cut longer names.
A purpose-built function module with INT8, UTCLONG, DATN and TIMN parameters, called by the reference client, settles their encoding (tests/golden/serialization/int8_utclong.json): - INT8 is signed 64-bit little-endian (was [ASSUMED]). - UTCLONG is 0 for initial, otherwise 1 + 100 ns ticks since 0001-01-01 on the Julian calendar before 1582-10-15 and Gregorian after it. Its metadata code 'p' was unknown, so UTCLONG parameters were dropped from the interface. Values are now YYYY-MM-DDTHH:MM:SS.fffffff strings (or datetime), None if initial. - DATN and TIMN travel as DATE and TIME; as unknown dictionary types they were dropped from structure layouts. The structure alignment table is now measured for every DDIC type against X030L-TABLEN (D34* align to 16, string references to 4), and table decoding accepts rows a server sends packed to the end of the last field. Types 33-40 stay [ASSUMED]: kernel 793 has no dictionary type for them.
About 60 comments cited "SDK type definitions", some with header line
numbers, and several fixture notes and docs named internal functions of
SAP binaries. API-parity notes now name the public SDK function they
mirror; wire facts cite a capture or are labelled [ASSUMED] (the RFC
server's return codes 3 and 16; analysis-only TLV tags).
Settled by new live captures of the reference client instead:
- packed decimal: 0x0D is negative, 0x0C zero/positive
(tests/golden/serialization/bcd_sign.json);
- the 0x0117 password scramble reproduces the reference client's
records (tests/golden/handshake/password_scramble.json, dummy
passwords against a non-existent user);
- UnitID and TID lengths.
Removes tests/golden/framing/trfc_call_request.{bin,json}: a synthetic
fixture of the old tRFC format, used by no test and contradicted by the
tRFC captures in tests/golden/trfc/. The hygiene test now also scans
fixture JSON and catches header line references.
Private addresses of the development lab (192.168.88.x, 10.20.30.x, and one message-server entry) and the capture host's name appeared in fixtures, tests and docs. They are replaced with documentation addresses (198.51.100.x / 192.0.2.x) and host1. Binary fixtures keep their byte length: ASCII and UTF-16LE text, raw IPv4 bytes and the 8-character address prefixes some GW frames carry are each substituted with a value of the same length, so every offset and length field is unchanged. The hygiene test now rejects these addresses in text and in any binary fixture. History is not rewritten.
Six independent reviews compared each doc claim with the implementation, the golden fixtures and the tests; about 140 corrections followed (offsets re-read from captures, hex examples regenerated, stale statements removed, cookbook examples fixed, unsourced claims labelled [ASSUMED] or removed). Status labels (CONFIRMED, RESOLVED, PARTIAL, UNCONFIRMED, [UNKNOWN]) are gone: an unlabelled fact cites its source inline, [ASSUMED] marks an inference, open items sit under Known Gaps. Enforced by the hygiene test and written down in CLAUDE.md and methodology.md. Code fixes the reviews surfaced: - STRING is UTF-8 plus a terminating NUL (live capture, string_xstring.json); the NUL was returned to the caller and not sent. The synthetic type_string/type_xstring fixtures that encoded the disproved layout are removed; type_bcd.json's value corrected to what its bytes encode. - The logon frame's footer length is computed instead of a constant. - connect_async() takes msserv/ms_http_port/ms_use_http and resolves groups like connect(). - SN in a built-in SNC partner name is serialNumber, as in the frame header's SNC name. - Stale code comments brought in line with the captures.
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
…pplied A TABLES parameter the caller filled and the function module then changed was missing from the result, and so was one it left alone. The server does not send such a table back: it sends a section per table (0x0331 .. 0x0336, keyed by the DM id the client assigned) holding the edits in order -- 0x0333 [op, dm, row] + 0x0334 row for append (4), insert (6) and change (7), 0x0332 [5, dm, row] for delete -- or the whole table under 0x0335 after a sort or a clear. The table is now rebuilt from the rows sent plus those edits, and an untouched one is returned as sent, as the reference client does. Every kind of edit was captured from a purpose-built function module and replays from tests/golden/serialization/table_delta.json; an edit outside that set raises. STFC_STRUCTURE's RFCTABLE now comes back with both rows (live test added).
tests/golden/ holds throwaway test keys, recorded ephemeral key-exchange keys and encrypted SNC records; all high-entropy, none a credential for a real system. Every new fixture raised a Generic High Entropy Secret alert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release 0.2.1. Closes #36 and #64. Full list in the
CHANGELOG.md0.2.1 entry.Fixed
call_transactional()now sends what the reference client sends, byte for byte: the call serialized intoARFC_DEST_SHIP'sDATAtable, with the TID, function and queue name in aSTATErow. Both row layouts come from the server's metadata. The function's own parameters are now sent (before, they were dropped).confirm_tid()sendsAPI_CLEAR_TID.tests/golden/trfc/trfc_reference.json.tests/golden/serialization/table_delta.json; for example,STFC_STRUCTURE'sRFCTABLEnow comes back with both rows.connect_async()resolves message-server groups the same wayconnect()does.SN=is read as serialNumber, matching how the SNC frame header encodes it.snc_sso="0"are no longer read by truthiness.Added
Evidence and docs
[ASSUMED]. They no longer cite SAP-internal names or SDK headers. New captures settled the negative packed-decimal sign and the password scramble instead of relabelling them.tests/test_repo_hygiene.pyenforces all of the above.Testing
Known gaps (not part of this PR)
SDATAcontainer format.