How can I access the attributes of a block within InnerBlocks?

Using the render_block filter (as opposed to wrapping the block with your custom block) is a simpler way to accomplish what you want. The filter runs for all blocks so you have to conditionally apply your logic to just the blocks you want. The attributes of each block will be available ($block[attrs]) and for the current core/gallery block the images attribute would have the data you want.

Something to watch out for is that the Gallery block is migrating to use nested Image blocks and will no longer keep a list of the images in an attribute of its own. That’s coming up in the 5.9 release.

Even then the render_block filter can be used for this but instead of checking the block attributes you’d iterate through $block['innerBlocks'] to get the image ids.

In case it helps here’s starter snippet, with a rudimentary condition to affect only gallery blocks with a specific class.

add_filter( 'render_block', function ( $block_content, $block ) {
    if (
        $block['blockName'] === 'core/gallery'
        && $block['attrs']['className'] === 'is-rad'
    ) {
        // $block also has 'innerBlocks'
        $block_content="whiz bang";
    }
    return $block_content;
}, 10, 2 );