Skip to content

v0.3.1

Choose a tag to compare

@joaquinbejar joaquinbejar released this 21 Jul 11:27
· 141 commits to main since this release
1110a14

IronFix 0.3.1

Security/robustness patch. Closes #4.

Unchecked arithmetic on attacker-controlled framing bytes

Three sibling sites folded untrusted BodyLength (9) / CheckSum (10) bytes without bounds. Each panicked under overflow-checks (dev/test/CI profiles, and hardened release builds) and wrapped silently under stock --release. All were reachable from the default public paths — Decoder::new(bytes).decode() and FixCodec::decode() — with no opt-out of checksum validation needed.

  • ironfix-tagvalue — decode path. body_start + body_length is now checked_add, mapping overflow to DecodeError::InvalidBodyLength. The decoder additionally validates the declared length against reality: body_end must land exactly on the first byte of the CheckSum field.
  • ironfix-transport — framing path. body_len_soh + 1 + body_length + 7 folded with checked_add → CodecError::InvalidBodyLength.
  • ironfix-tagvalue — checksum parse. parse_checksum folded d0 * 100 in u8, overflowing for any hundreds digit >= 3 (e.g. an injected mid-body 10=624, which decode() reaches for any tag-10 occurrence, not only the trailing one). It now folds in u16 and range-checks the result, so 999/624/300/256 are rejected.

Zero-padded tag handling

The CheckSum field offset is now tracked during the field scan instead of being derived as value_ptr - 3. That derivation assumed a literal 10= and mis-located zero-padded tags such as 010=, which parse_tag folds numerically — the same blind spot that defeated hand-mirrored downstream guards, and which also mis-computed the checksummed byte span.

Behaviour change

Decoder::decode() now rejects a BodyLength that does not match the actual body length; previously any value was accepted. A mismatch is a malformed frame per FIX, but callers that fed hand-written messages with a placeholder 9= value will now get DecodeError::InvalidBodyLength.

Tests

Seven regression tests: usize::MAX BodyLength via 9= and 009=, length mismatch, valid frame still decodes, trailing 010= checksum, mid-body 10=624, codec overflow and MessageTooLarge, and parse_checksum out-of-range.

All 11 crates published to crates.io at 0.3.1.

Full changelog: v0.3.0...v0.3.1