It depends how it is implemented. After extracting the ID and looking up the post you can then check that the "slug" matches. Return a 404 if it doesn't.
This may add a bit of complexity (if the slug data is mutable you need to allow any past versions or freeze it in creation) but isn't too hard if this is the approach that you want to take.
This may add a bit of complexity (if the slug data is mutable you need to allow any past versions or freeze it in creation) but isn't too hard if this is the approach that you want to take.