The microcontroller throws an error when I'm trying to modify its flash.

The memory looks to be unlocked, here is screenshot of option bytes

The microcontroller is soldered into a custom board, with power and reset circuit as on the image below.

What I've tried:
Initially, the microcontroller was trying to execute instructions from "outside of program code", 0x1fffxxxx range. It happened randomly, the device managed to startup, call HAL_Init, configure clock. I did some switching back and forth with nBOOT0 and nBOOT1 option bytes, and the device started working fine. I did not understand what was the issue and switched them again to try and reproduce the issue. After that the microcontroller refused to write into flash any more...
I seem to be able to write into WRP1A_STRT and WRP1B_STRT, though it doesn't seem to unlock the flash. WRP2A_STRT and WRP2B_STRT will switch back to 0x00 if I try to modify them. I suspect it's because the device does not have second bank of memory, so it shouldn't affect the flash protection.
I watched SWDCLK, SWDIO and power pins with an oscilloscope, they look completely healthy.
Interestingly, CubeProgrammer and ST-Link read different data out of the device. Not sure why, and if it's connected to the issue. The data doesn't change over time though.

Please suggest what may be the issue or what else I could check.