Skip to content

Fix/validate packet fields - #9

Merged
ashleyhindle merged 2 commits into
WhispPHP:mainfrom
malekkadri:fix/validate-packet-fields
Oct 22, 2026
Merged

ashleyhindle merged 2 commits into
WhispPHP:mainfrom
malekkadri:fix/validate-packet-fields

Conversation

@malekkadri

Copy link
Copy Markdown
Contributor

Summary

Improve SSH packet parsing by rejecting incomplete fields instead of attempting to unpack insufficient data or accepting truncated strings.

Changes

  • Validate the 4-byte length prefix for SSH strings.
  • Ensure the complete declared string is available before extraction.
  • Reject incomplete uint32 fields.
  • Detect missing fields during formatted extraction.
  • Preserve the string offset when validation fails.
  • Add regression tests for malformed and truncated packet fields.

Testing

  • Added focused Pest regression tests covering malformed SSH fields.
  • Full Pest suite and PHP Pint checks are pending validation.

Scope

Changes are limited to src/Packet.php and tests/Unit/PacketTest.php.

@ashleyhindle
ashleyhindle merged commit 55b473d into WhispPHP:main Oct 22, 2026
3 checks passed
@ashleyhindle

Copy link
Copy Markdown
Collaborator

Thanks @malekkadri 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants