The vulnerability CVE-2025-48756 exists in the scsir crate (version <= 0.2.0) because the WriteSameCommand::group_number function does not validate that the input value conforms to the hardware-defined bit-width for the 'group number' field in SCSI Write Same commands (typically 5 bits).
The group_number function directly assigns the provided u8 value to an internal field. This field is later used by the issue_10, issue_16, and issue_32 functions to populate the respective command buffers (CommandBuffer10, CommandBuffer16, CommandBuffer32). These command buffer structures define group_number as a 5-bit field. If a value larger than what can be represented in 5 bits (i.e., > 31) is passed to the group_number function, it will be truncated when written into the command buffer. This truncation leads to the SCSI device receiving a different group_number than intended, potentially causing an overflow or other undefined behavior on the hardware device.
The issue report (https://github.com/maboroshinokiseki/scsir/issues/4) explicitly points out this lack of input validation in the group_number function and provides a proof-of-concept that demonstrates the overflow by calling scsi.write().group_number(255).issue_16().
While later versions of the code (as seen in the fetched file content, which might be newer than 0.2.0) include a check (bitfield_bound_check!) within an error_check function that is called by issue_10/16/32, the vulnerability lies in the fact that in version 0.2.0 and earlier, this check was either not present or not effective in the group_number setter itself, allowing an invalid value to be stored and subsequently used.