DBMS_METADATA.GET_DDL command

DBMS_METADATA.GET_DDL Does Not Return Hashed Passwords Anymore

If you have been using DBMS_METADATA.GET_DDL to extract user DDLs along with their hashed passwords, you should be aware that starting with Oracle DataPump Bundle Patch 19.17 (which includes the fix for bug 33517865), a significant change has been introduced. The function no longer includes password hashes in the output, and this change is intentional, driven by security enhancements.

In older Oracle releases (Earlier than 11g) , simply having the SELECT_CATALOG_ROLE role or SELECT_ANY_DICTIONARY system privilege was enough to extract the full CREATE USER DDL statement , including the hashed password, like this:

This output included the IDENTIFIED BY VALUES clause with the hashed password, which was useful for cloning users, storing user passwords history or migrating accounts across environments.

Over time(11g and later), Oracle tightened security. It became necessary to grant the user the EXP_FULL_DATABASE role to extract hashed passwords with DBMS_METADATA.GET_DDL. The reason? Oracle demanded more privileges than just SELECT_CATALOG_ROLE. Dbms_metadata.get_ddl(‘USER’,'<username>’) Does Not Return A Password Value (Doc ID 1529478.1) EXP_FULL_DATABASE role already involves SELECT_CATALOG_ROLE and EXECUTE_CATALOG_ROLE.

This approach was strongly discouraged, but it was also possible by setting the O7_DICTIONARY_ACCESSIBILITY parameter to TRUE, which bypasses the limitations and allows access to objects in the SYS schema with SELECT ANY TABLE system privilege. This parameter was deprecated in 18c and completely desupported in 19c.

With the Data Pump Bundle Patch 19.17 and newer, Oracle has included a fix for Bug 33517865. Even if you have both the EXP_FULL_DATABASE and SELECT_CATALOG_ROLE privileges, you will no longer be able to view hashed passwords. This is a deliberate security hardening measure designed to prevent unauthorized access to password hash data.

For those who do have a legitimate need to access user password hashes: such as for backing up or controlled migration scenarios. Oracle provided a way with Bug Fix 35018026 ships with Data Pump Bundle Patch 19.19 and later on. This fix restores the behavior, but only if the executing user has explicit READ or SELECT privileges on the underlying dictionary table (SYS.USER$).

Requirements:
You must apply the fix for Bug 35018026 (shipped with DPBP 19.19 and later).
The user running the query must have SELECT or READ privilege on SYS.USER$.

Once these conditions are met, DBMS_METADATA.GET_DDL can again return hashed passwords, but only for users who are explicitly authorized to see them.

It’s important to understand why you might or might not be seeing this behavior, depending on how you patch your environment.

The change described above is included only in the Data Pump Bundle Patches, not in standard Release Updates (RUs). That’s because of the Data Pump patches are currently non-RAC rolling and thus are delivered separately. Mike Dietrich explains this well in his blog post:
Apply the Data Pump Bundle Patch – non-rolling but online. Oracle is working on enhancing the Data Pump patching process, potentially integrating it with RUs in the future. For now, though, you’ll need to apply the Data Pump Bundle Patch manually if you want these changes.

Instead of granting direct SELECT access on SYS.USER$ to USER_XXX, a PL/SQL function can be created under the SYS schema with definer rights. This function would be solely responsible for returning hashed passwords only for allowed users, making it possible to implement row-level security on SYS.USER$

Here is a sample PL/SQL function that returns the hashed passwords of all users except SYS.

Grant the EXECUTE privilege to the user who needs access to hashed passwords.

Here’s a quick sample to test it out. First, we grant the EXP_FULL_DATABASE role to USER_XXX, and then use the sample SQL query below to retrieve usernames and their hashed passwords

With recent Oracle Data Pump patches (involving bug fix 33517865), access to hashed passwords via DBMS_METADATA.GET_DDL is no longer available by default even for users with granted roles like EXP_FULL_DATABASE. This change, introduced as part of security-focused fixes, enforces stricter controls over sensitive data exposure. However, for legitimate administrative needs, Oracle provides controlled methods (with bug fix 35018026), such as granting SELECT access on SYS.USER$ directly, or using a definer-rights PL/SQL function created under the SYS schema.

Hope it helps.


Discover More from Osman DİNÇ


Comments

Leave your comment