What to try if MetaDefender Core fails to start with 'permission denied for schema information_schema' (rc -13) on AWS RDS PostgreSQL ?

Summary 

MetaDefender Core stops at startup when its PostgreSQL user cannot read information_schema on AWS RDS. The fix is one SQL command, run as the RDS master user: grant the role mdcore_private_role to the database user Core connects with, then restart the Core service. 

Symptoms 

The MetaDefender Core service shuts down at startup and logs the following error: 

(common.base) Error in Service, shutdown.., error='Extension setting up failed: extension: 'dbpg', rc: '-13', error: 'Failed to provision private group role, error=ERROR: permission denied for schema information_schema'' [msgid: 130] 

In pgAdmin, running GRANT USAGE ON SCHEMA information_schema TO postgres; returns ERROR: permission denied for schema information_schema (SQL state 42501). “postgres” is the user used for MD Core integration. 

Cause 

The PUBLIC role no longer has USAGE on the information_schema schema, so the database user Core connects with cannot read it. The dbpg extension queries information_schema while it provisions its private group role, and fails with permission denied. 

The schema's access list in the affected database showed only two entries, both granted by rdsadmin: 

rdsadmin=UC/rdsadmin,mdcore_private_role=UC/rdsadmin 

A healthy database also has an =U/rdsadmin entry, which is PUBLIC USAGE. pg_catalog in the same database still had it. The exact trigger for the revoke was not identified: it may come from a hardening or compliance script, or from the update process. This is a likely explanation, not a confirmed one. We strongly recommend to start an investigation with AWS Support regarding permissions/ACL changes. 

Diagnosis 

Connect to the metadefender_core database as the RDS master user (for example in pgAdmin) and run each query separately, because pgAdmin shows only the last result set. 

  1. Check whether the Core database user can use the schema. false confirms the problem. 

SELECT has_schema_privilege('postgres', 'information_schema', 'USAGE'); 

  1. Check whether the user is already a member of the role that does have access. 

SELECT pg_has_role('postgres', 'mdcore_private_role', 'member'); 

Replace postgres with the username from Core's database settings if it differs. 

Resolution 

Grant the existing mdcore_private_role to the database user Core connects with. That role already holds USAGE and CREATE on information_schema, so the user inherits the access without any change to the rdsadmin-owned ACL. 

  1. Stop the MetaDefender Core service. 

  1. Connect to the metadefender_core database as the admin or RDS master user. 

  1. Run the grant. This is the command that resolved the issue: 

GRANT mdcore_private_role TO postgres WITH INHERIT TRUE; 

 
On PostgreSQL 15 or older, WITH INHERIT TRUE is not supported. Use GRANT mdcore_private_role TO postgres; instead. 

  1. If Core uses a different database user, grant the role to that user instead: 

GRANT mdcore_private_role TO your_core_db_user WITH INHERIT TRUE; 

  1. Start the MetaDefender Core service. 

 

IMPORTANT: If password of PostgreSQL user used for integration with MD Core was changed in the meantime, we recommend to use CLI tool for changing MD Core configuration for integration with PostgreSQL: https://www.opswat.com/docs/mdcore/configuration/database-management#cli-tool-ometascan-change-db-credentials  

Support:

If you need further assistance, please contact OPSWAT Support through the OPSWAT Portal or your assigned support representative.