Skip to content

[Data][Serve][Autoscaler] Mark non-security hash uses with usedforsecurity=False - #66201

Closed
toabctl wants to merge 1 commit into
ray-project:masterfrom
toabctl:fips-md5-usedforsecurity
Closed

toabctl wants to merge 1 commit into
ray-project:masterfrom
toabctl:fips-md5-usedforsecurity

Conversation

@toabctl

@toabctl toabctl commented Sep 16, 2026 •

Copy link
Copy Markdown

Description

hashlib.md5() raises on FIPS-enabled OpenSSL, since MD5 isn't in the FIPS provider:

ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

hashlib.blake2b() is served by the _blake2 builtin rather than by OpenSSL, so it
does not go through that path — but distributions that wrap the builtin constructors
when _hashlib.get_fips_mode() is set reject it the same way, with
ValueError: blake2b is blocked when usedforsecurity=True. Both need the same fix.

#40755 fixed this for runtime_env by switching to SHA-1, which the FIPS provider does
allow. These five calls are what's left, and in each one the digest value matters so
the algorithm can't change:

  • _generate_arm_guid replicates ARM's guid(), which is defined as MD5
  • _rewrite_iceberg_file needs a stable write_uuid so retries overwrite the same
    object, and uuid.UUID wants 128 bits anyway
  • _compute_row_hashes uses the digest as a reproducible 64-bit seed
  • Dataset.train_test_split buckets rows by a digest of the split key
  • get_worker_id derives a Dynamo worker id from a replica's unique id

None of them is a security use, and usedforsecurity=False leaves the digests
identical, so nothing changes off FIPS. Needs Python 3.9+; SUPPORTED_PYTHONS is 3.10+.

Related issues

Same cause as #40534 / #40755. Not #53435 — SHA-1 is allowed in the FIPS provider and
doesn't raise, so the remaining runtime_env SHA-1 uses are unaffected either way.

Checks

  • black (22.10.0) and ruff (0.8.4), the pinned pre-commit versions, are clean on
    all five files
  • Verified no unguarded md5/blake2b call remains anywhere under python/ray
    (AST walk, excluding tests)
  • Digests are byte-identical with and without the kwarg

@toabctl
toabctl force-pushed the fips-md5-usedforsecurity branch from ca6d1f9 to 579e7ce Compare September 16, 2026 08:59
@toabctl
toabctl marked this pull request as ready for review September 16, 2026 10:32
@toabctl
toabctl requested review from a team, alimaazamat and marosset as code owners September 16, 2026 10:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates several instances of md5 hashing across the codebase to explicitly set usedforsecurity=False, ensuring compatibility with FIPS-compliant environments where standard MD5 usage is restricted. There are no review comments to address, and I have no additional feedback to provide.

@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Sep 16, 2026
…urity=False

hashlib.md5() raises on FIPS-enabled OpenSSL because MD5 isn't in the
OpenSSL FIPS provider. hashlib.blake2b() is served by the _blake2 builtin
rather than OpenSSL, but distributions that wrap the builtins when
_hashlib.get_fips_mode() is set reject it the same way, so both need the
same treatment.

ray-project#40755 fixed this for runtime_env by moving to SHA-1, which the FIPS
provider does allow. These five calls are what is left, and in each the
digest value matters so the algorithm can't change:

- _generate_arm_guid replicates ARM's guid(), which is defined as MD5
- _rewrite_iceberg_file needs a stable write_uuid so retries overwrite
  the same object, and uuid.UUID wants 128 bits anyway
- _compute_row_hashes uses the digest as a reproducible 64-bit seed
- Dataset.train_test_split buckets rows by a digest of the split key
- get_worker_id derives a Dynamo worker id from a replica's unique id

All five derive an identifier from a string rather than doing anything
security related, so usedforsecurity=False fits, and it leaves the
digests identical.

Signed-off-by: Thomas Bechtold <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@toabctl
toabctl force-pushed the fips-md5-usedforsecurity branch from 579e7ce to b6e6eee Compare September 24, 2026 14:57
@toabctl
toabctl requested a review from a team as a code owner September 24, 2026 14:57
@toabctl toabctl changed the title [Data][Autoscaler] Mark non-security MD5 uses with usedforsecurity=False [Data][Serve][Autoscaler] Mark non-security hash uses with usedforsecurity=False Sep 24, 2026
@toabctl

toabctl commented Sep 24, 2026

Copy link
Copy Markdown
Author

@dstrodtman could you maybe have a look at this? or point to somebody who could?

dstrodtman added a commit that referenced this pull request Sep 24, 2026
## Description

Since #66357, `import ray.data` loads `pyarrow.dataset` and its native
extensions. The legacy `parquet_datasource.py` now imports
`_compute_row_hashes` from the V2 readers package at module level, and
the V2 reader modules import `pyarrow.dataset` at load time. Before
#66357, the dependency ran the other way and `ray.data` never reached
`pyarrow.dataset` on import.

This PR moves the `_compute_row_hashes` import into
`_read_batches_from`, its only caller. That matches the file's existing
function-level `pyarrow.dataset` imports. The import points at
`readers/synthesized_columns.py`, where the helper has lived since
#66390, rather than at the `file_reader` re-export. Importing from
`synthesized_columns` at module level isn't enough on its own, because
`read_units.py` also imports `pyarrow.dataset` at the top level.

It also adds `test_import_does_not_load_pyarrow_dataset` to
`python/ray/data/tests/test_import.py`. The test asserts that a fresh
driver's `import ray.data` loads no `pyarrow._dataset*` modules.

### Why this matters

The Ray docs Read the Docs build has been segfaulting intermittently, in
about 31% of builds since 2026-09-23. The crash is in native extension
init while autosummary imports RLlib → Tune → AIR → `ray.data`. A
`PYTHONFAULTHANDLER=1` traceback (#66452) puts the crash inside `from
pyarrow._dataset_parquet import ...`, which is reached from
`parquet_datasource.py` → `file_reader.py` → `import pyarrow.dataset`.
The loaded-extensions list in that traceback ends with exactly the
modules this import adds.

This change takes the crashing import off the `import ray.data` path. It
doesn't fix the underlying native crash. I couldn't reproduce it with a
bare `import pyarrow.dataset` loop in `linux/amd64` Docker: 0 of 300
runs failed, with numpy 2.2.6 and pyarrow 23.0.1 from the doc lock. So
it seems to depend on process state or on the build host. The docs build
and `requirements_compiled.txt` both pin pyarrow 23.0.1, and neither pin
changed in the failure window.

## Related issues

Related to #66357 and #66452.

## Additional information

### Not a duplicate

Searched open PRs for `_compute_row_hashes`, the DSv2 reorg series, and
lazy-import and segfault keywords. #66450 (DSv2 Reorg [4/6]) and #66201
are the nearest open PRs, and neither touches this import or
`test_import.py`.

### Tests run

These were run locally on macOS arm64, Python 3.11, pyarrow 23.0.1,
numpy 2.2.6. They used the Ray nightly wheel with `ray/data` and
`ray/tests` linked from this branch.

* `pytest python/ray/data/tests/test_import.py`: 2 passed. With the
`parquet_datasource.py` change reverted, the new test fails and lists
`pyarrow._dataset`, `_dataset_orc`, `_dataset_parquet`, and
`_dataset_parquet_encryption`.
* `pytest python/ray/data/tests/datasource/test_parquet.py -k row_hash`:
18 passed.
* `pytest python/ray/data/tests/datasource/test_parquet.py` (full
module): 242 passed, 13 skipped, 13 failed, 34 errors. Rerunning the 47
failing tests with master's `parquet_datasource.py` gave an identical
failing set, so none come from this change. They come from the local
environment:
* The S3 fixtures error in `fsspec`'s HTTP backend, because their test
dependencies aren't installed.
* Several local-path tests assert `string` columns and get
`large_string`, which is pandas/pyarrow version skew against CI's pins.

  CI is the authoritative run for this module.
* `pre-commit run --files
python/ray/data/_internal/datasource/parquet_datasource.py`: all hooks
passed, including ruff, black, pydoclint, and the import-order check.

### AI assistance

AI assistance (Claude Code) was used to investigate the import graph,
write the change and test, and draft this description. This PR stays in
draft until the submitter has reviewed every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…6463)

## Description

Since ray-project#66357, `import ray.data` loads `pyarrow.dataset` and its native
extensions. The legacy `parquet_datasource.py` now imports
`_compute_row_hashes` from the V2 readers package at module level, and
the V2 reader modules import `pyarrow.dataset` at load time. Before
ray-project#66357, the dependency ran the other way and `ray.data` never reached
`pyarrow.dataset` on import.

This PR moves the `_compute_row_hashes` import into
`_read_batches_from`, its only caller. That matches the file's existing
function-level `pyarrow.dataset` imports. The import points at
`readers/synthesized_columns.py`, where the helper has lived since
ray-project#66390, rather than at the `file_reader` re-export. Importing from
`synthesized_columns` at module level isn't enough on its own, because
`read_units.py` also imports `pyarrow.dataset` at the top level.

It also adds `test_import_does_not_load_pyarrow_dataset` to
`python/ray/data/tests/test_import.py`. The test asserts that a fresh
driver's `import ray.data` loads no `pyarrow._dataset*` modules.

### Why this matters

The Ray docs Read the Docs build has been segfaulting intermittently, in
about 31% of builds since 2026-09-23. The crash is in native extension
init while autosummary imports RLlib → Tune → AIR → `ray.data`. A
`PYTHONFAULTHANDLER=1` traceback (ray-project#66452) puts the crash inside `from
pyarrow._dataset_parquet import ...`, which is reached from
`parquet_datasource.py` → `file_reader.py` → `import pyarrow.dataset`.
The loaded-extensions list in that traceback ends with exactly the
modules this import adds.

This change takes the crashing import off the `import ray.data` path. It
doesn't fix the underlying native crash. I couldn't reproduce it with a
bare `import pyarrow.dataset` loop in `linux/amd64` Docker: 0 of 300
runs failed, with numpy 2.2.6 and pyarrow 23.0.1 from the doc lock. So
it seems to depend on process state or on the build host. The docs build
and `requirements_compiled.txt` both pin pyarrow 23.0.1, and neither pin
changed in the failure window.

## Related issues

Related to ray-project#66357 and ray-project#66452.

## Additional information

### Not a duplicate

Searched open PRs for `_compute_row_hashes`, the DSv2 reorg series, and
lazy-import and segfault keywords. ray-project#66450 (DSv2 Reorg [4/6]) and ray-project#66201
are the nearest open PRs, and neither touches this import or
`test_import.py`.

### Tests run

These were run locally on macOS arm64, Python 3.11, pyarrow 23.0.1,
numpy 2.2.6. They used the Ray nightly wheel with `ray/data` and
`ray/tests` linked from this branch.

* `pytest python/ray/data/tests/test_import.py`: 2 passed. With the
`parquet_datasource.py` change reverted, the new test fails and lists
`pyarrow._dataset`, `_dataset_orc`, `_dataset_parquet`, and
`_dataset_parquet_encryption`.
* `pytest python/ray/data/tests/datasource/test_parquet.py -k row_hash`:
18 passed.
* `pytest python/ray/data/tests/datasource/test_parquet.py` (full
module): 242 passed, 13 skipped, 13 failed, 34 errors. Rerunning the 47
failing tests with master's `parquet_datasource.py` gave an identical
failing set, so none come from this change. They come from the local
environment:
* The S3 fixtures error in `fsspec`'s HTTP backend, because their test
dependencies aren't installed.
* Several local-path tests assert `string` columns and get
`large_string`, which is pandas/pyarrow version skew against CI's pins.

  CI is the authoritative run for this module.
* `pre-commit run --files
python/ray/data/_internal/datasource/parquet_datasource.py`: all hooks
passed, including ruff, black, pydoclint, and the import-order check.

### AI assistance

AI assistance (Claude Code) was used to investigate the import graph,
write the change and test, and draft this description. This PR stays in
draft until the submitter has reviewed every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 9, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

@github-actions github-actions Bot closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant