This is why newer versions of MacOS require you to grant permissions for an application to access folders in your user account. If you keep the keepass database in a folder like "secure", then no other program will be able to get to it. On Linux, there are a ton of ways of implementing something similar.
KeepassXC requires authorizing a plugin, and authorizing specific sites before it releases a password.