You’re exactly right. Put a rectangle in the very back (rounded) with space above the top of the content. You can put another rectangle on the bottom with no rounding.
In this example, I have it exactly how you describe it. The blue “Cancel” button has rounded corners on the top. The dark grey rectangle has 1 rounded corner on the top-right.