[BugFix] [Vul] Add missing usedforsecurity=False in MD5 hashing to enable FIPS (#18319)

Signed-off-by: cascade812 <cascade812@outlook.com>
Signed-off-by: shaoyuyoung <shaoyuyoung@gmail.com>
Co-authored-by: cascade <cascade812@outlook.com>
This commit is contained in:
Shaoyu Yang 2025-05-19 16:31:23 +08:00 committed by GitHub
parent 275c5daeb0
commit d637b96099
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -143,8 +143,8 @@ class NeuronCausalLM(nn.Module):
config = neuronx_model_cls.get_config_cls()(
neuron_config,
load_config=load_pretrained_config(model_name_or_path))
hashed_config = hashlib.md5(
config.to_json_string().encode('utf-8')).hexdigest()
hashed_config = hashlib.md5(config.to_json_string().encode('utf-8'),
usedforsecurity=False).hexdigest()
if os.getenv("NEURON_COMPILED_ARTIFACTS") is not None:
compiled_model_path = os.getenv("NEURON_COMPILED_ARTIFACTS")
elif os.path.exists(model_name_or_path):
@ -263,8 +263,8 @@ class NeuronMllamaForCausalLM(nn.Module):
config = neuronx_model_cls.get_config_cls()(
neuron_config,
load_config=load_pretrained_config(model_name_or_path))
hashed_config = hashlib.md5(
config.to_json_string().encode('utf-8')).hexdigest()
hashed_config = hashlib.md5(config.to_json_string().encode('utf-8'),
usedforsecurity=False).hexdigest()
if os.getenv("NEURON_COMPILED_ARTIFACTS") is not None:
compiled_model_path = os.getenv("NEURON_COMPILED_ARTIFACTS")
elif os.path.exists(model_name_or_path):
@ -426,8 +426,8 @@ class NeuronSpeculationCausalLM(nn.Module):
config.fused_spec_config = fused_spec_config
self.config.neuron_config = neuron_config
hashed_config = hashlib.md5(
config.to_json_string().encode('utf-8')).hexdigest()
hashed_config = hashlib.md5(config.to_json_string().encode('utf-8'),
usedforsecurity=False).hexdigest()
if os.getenv("NEURON_COMPILED_ARTIFACTS") is not None:
compiled_model_path = os.getenv("NEURON_COMPILED_ARTIFACTS")
elif os.path.exists(model_name_or_path):