Skip to content

Fix commonprefix security issue, add ESTALE retry, and tests - #371

Open
arijitroy003 wants to merge 2 commits into
dbt-labs:mainfrom
arijitroy003:fix/commonprefix-security-and-improvements
Open

arijitroy003 wants to merge 2 commits into
dbt-labs:mainfrom
arijitroy003:fix/commonprefix-security-and-improvements

Conversation

@arijitroy003

Copy link
Copy Markdown

Summary

  • Security fix: Replace os.path.commonprefix with os.path.commonpath in untar_package(). commonprefix is string-based (not path-aware) and can return incorrect results for paths with shared prefixes that are not actual common directories. The safe_extract function was already fixed, but untar_package still had the vulnerable call.

  • Stale file handle retry (fixes [Bug] dbt Core 1.9 - Intermittent error "OSError: [Errno 116] Stale file handle" during parsing #360): Add retry with exponential backoff for ESTALE (errno 116) in load_file_contents(). This handles transient stale file handle errors on NFS/GCS FUSE/network-mounted filesystems, as reported in [Bug] dbt Core 1.9 - Intermittent error "OSError: [Errno 116] Stale file handle" during parsing #360. Uses the approach suggested by @dbeatty10: 3 retries with 0.1s base backoff.

  • Test coverage: Add unit tests for previously uncovered pure functions:

    • utils/encoding.py: md5(), JSONEncoder, ForgivingJSONEncoder
    • utils/dict.py: deep_merge (nested, empty, mutation safety), merge, filter_null_values
    • clients/system.py: ESTALE retry behavior, commonpath correctness in untar_package
  • SECURITY.md: Add security policy based on the dbt-labs org template, with areas of interest specific to this repo (tarball extraction, file I/O, subprocess execution, network downloads).

Test plan

  • All 24 new tests pass (pytest tests/unit/test_encoding.py tests/unit/test_dict_utils.py tests/unit/test_system.py)
  • Existing test suite unaffected
  • CI passes

…Y.md

- Replace os.path.commonprefix with os.path.commonpath in untar_package
  to fix remaining path traversal vulnerability (commonprefix is
  string-based, not path-aware)
- Add retry with exponential backoff for ESTALE (errno 116) in
  load_file_contents to handle stale file handles on NFS/FUSE mounts
  (fixes dbt-labs#360)
- Add unit tests for encoding.py (md5, JSONEncoder, ForgivingJSONEncoder)
- Add unit tests for dict.py (deep_merge, merge, filter_null_values)
- Add unit tests for system.py (ESTALE retry, commonpath fix)
- Add SECURITY.md based on dbt-labs org security policy template
@arijitroy003
arijitroy003 requested a review from a team as a code owner July 16, 2026 21:14
@cla-bot cla-bot Bot added the cla:yes label Jul 16, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@arijitroy003

Copy link
Copy Markdown
Author

Friendly bump — this has been open for ~12 days. Happy to address any feedback or make changes if needed. Let me know if there's anything I should adjust.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] dbt Core 1.9 - Intermittent error "OSError: [Errno 116] Stale file handle" during parsing

1 participant