The accepted answer works, but indeed it removes the box shadow. A comment I saw in this github post says that it can be also fixed by creating a new stacking context (kind of moving an element into a new painting layer). That can be achieved with a small hack like
transform: translateZ(0)
In my case, both overflow and box-shadow are working with this solution.
UPD: just like @JadHaidar suggested in the comments isolation is a property specifically for working with the stacking context:
isolation: isolate;