Skip to content

Prevent shadow password hash leakage via OVAL results - #2415

Open
Arden97 wants to merge 3 commits into
OpenSCAP:mainfrom
Arden97:pswd_hash_leak
Open

Arden97 wants to merge 3 commits into
OpenSCAP:mainfrom
Arden97:pswd_hash_leak

Conversation

@Arden97

@Arden97 Arden97 commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR fixes the problem with raw shadow password hashes appearing in OVAL results with two complementary approaches:

  • shadow_probe.c: New strip_hash() function replaces raw password hashes with prefix+id values before they enter the OVAL data pipeline
  • oval_sysEnt.c, oval_recordField.c: The mask attribute now suppresses values in both oval_results and oval_system_characteristics outputs

Rationale

  • The shadow probe unconditionally includes raw password hashes from /etc/shadow in collected OVAL items
  • The OVAL mask attribute can suppress these values in results output, but only when the content
    author sets mask="true" AND the output format is oval_results
  • Standalone system characteristics export (oval_system_characteristics) always writes the full hash regardless of mask

Testing

  • ctest -R shadow runs all shadow probe tests including the new test_probes_shadow_stripped test
  • The new test creates a fake /etc/shadow with 5 entry types (SHA-512 hash, locked+hash, locked-no-hash, disabled, never-set), evaluates via offline mode, and verifies:
    • Stripped password values match expected states (e.g. $6$ for SHA-512, !!$6$ for locked+SHA-512)
    • No raw hash material appears anywhere in results XML

@Mab879

Mab879 commented Sep 24, 2026

Copy link
Copy Markdown
Member

Looking at the testing farm results something seems off. Please take a look.

@sonarqubecloud

Copy link
Copy Markdown

@Arden97

Arden97 commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Looking at the testing farm results something seems off. Please take a look.

@Mab879 Updated. Had to include hash stripping mechanism in to shadow probe testing scripts for consistency

@Mab879 Mab879 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments and review the Sonar findings as well.

prefix_len = 0;

/* crypt(3) hash ($id$salt$hash), keep lock prefix + method id ($id$) */
while (*p == '!')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this code is expecting $ to be in the hash format. After reading man 5 crypt that assumption isn't always true. We might want change how this handled.

{
SEXP_t *un;
struct result_info r;
char stripped[8];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not in Fedora or RHEL there could be longer hash format. This static size might cause us issues later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants