🐛 [BUG] - Conformance - sa_setARSNW Does Not Enforce the SA's Authentication-Capability Precondition
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 169
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Description
Bug Report: sa_setARSNW Does Not Enforce the SA's Authentication-Capability Precondition
Summary
| Field | Value |
|---|---|
| Product | NASA CryptoLib (SDLS Protocol Implementation) |
| Version | 1.4.2 & dev branch - the details are specific to v1.4.2 |
| Component | src/sa/internal/sa_interface_inmemory.template.c — sa_setARSNW |
| Issue | sa_setARSNW does not evaluate whether the target SA is authentication-capable before writing its anti-replay window field |
| Bug Type | Conformance |
| Severity | Medium |
| Impact | The anti-replay sequence-number window can be set on an SA that isn't configured for authentication at all (e.g. a plaintext or encryption-only SA) — a value with no protocol meaning on that SA is silently written and reported as accepted |
Description
An SA's est/ast service-type flags determine whether authentication is part of that SA's
security service. The anti-replay window (arsnw) only has meaning for an SA that provides
authentication — it's the tolerance window used when validating an incoming authenticated
frame's sequence number.
sa_setARSNW reads the target SPI, bounds-checks it against NUM_SA, and — if in range —
unconditionally writes sa[spi].arsnw from the wire. It never inspects sa[spi].est/ast
before doing so. Any in-bounds SPI accepts an ARSNW update regardless of whether that SA
actually uses authentication.
Affected Code
sa_setARSNW (src/sa/internal/sa_interface_inmemory.template.c:1730-1775)
static int32_t sa_setARSNW(TC_t *tc_frame)
{
...
if (spi < NUM_SA)
{
if (sa[spi].arsnw_len > (ARSN_SIZE)) { sa[spi].arsnw_len = ARSN_SIZE; }
sa[spi].arsnw = (((uint8_t)sdls_frame.tlv_pdu.data[2])); // no est/ast check anywhere
}
else { ... }
return CRYPTO_LIB_SUCCESS;
}
There is no est/ast (or any other service-type) condition anywhere in this function's body —
verified by reading the function in full.
Reproduction Sequence (from the fuzzing logs)
Two-frame sequence: create a non-authentication-capable SA, then set its ARSNW.
| # | Direction | Hex | Meaning |
|---|---|---|---|
| 1 | ground → flight | 002c10a6000000001104d0003f0c001001020c00000000000000000000000001010080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ab0 |
TC frame, SA Create, SPI 63, est=0/ast=0 (no auth service) |
| 2 | ground → flight | 002c100e00000000150010003f9fcb |
TC frame, sg=0x1, pid=0x5 (SA SetARSNW), SPI 63 |
Debug replay of frame 2:
SA setARSNW
spi = 63
ARSN set to: 0
Status code: 0
No diagnostic at all is printed for the auth-capability precondition — unlike its sa_setARSN
sibling (which does evaluate and log this same precondition, just doesn't propagate the
failure), sa_setARSNW never attempts the check in the first place. The oracle model correctly
rejects this exact same two-frame sequence with SetARSNW(): SA does not have authentication service, cannot set ARSNW.
Discovered using the StratoFuzz protocol fuzzing framework.
Branch Name
dev
Reproduction steps
## Reproduction Sequence (from the fuzzing logs)
Two-frame sequence: create a non-authentication-capable SA, then set its ARSNW.
| # | Direction | Hex | Meaning |
|---|-----------|-----|---------|
| 1 | ground → flight | `002c10a6000000001104d0003f0c001001020c00000000000000000000000001010080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ab0` | TC frame, SA Create, SPI 63, `est=0/ast=0` (no auth service) |
| 2 | ground → flight | `002c100e00000000150010003f9fcb` | TC frame, `sg=0x1, pid=0x5` (SA SetARSNW), SPI 63 |
Debug replay of frame 2:
SA setARSNW
spi = 63
ARSN set to: 0
Status code: 0
No diagnostic at all is printed for the auth-capability precondition — unlike its `sa_setARSN`
sibling (which does evaluate and log this same precondition, just doesn't propagate the
failure), `sa_setARSNW` never attempts the check in the first place. The oracle model correctly
rejects this exact same two-frame sequence with `SetARSNW(): SA does not have authentication
service, cannot set ARSNW`.
Screenshots
Logs
OS
Linux
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/sa/internal/sa_interface_inmemory.template.c, at sa_setARSNW around lines 1730-1775, and compare its checks with the sa_setARSN sibling. Replay the two-frame sequence in the issue against an SA with est=0/ast=0. Done means the non-authentication-capable SA does not accept the ARSNW update and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100