Refactor: Enforce explicit problem type validation in config loader#973
Open
RinZ27 wants to merge 1 commit intoh2oai:mainfrom
Open
Refactor: Enforce explicit problem type validation in config loader#973RinZ27 wants to merge 1 commit intoh2oai:mainfrom
RinZ27 wants to merge 1 commit intoh2oai:mainfrom
Conversation
…ig_utils Prevent arbitrary module loading by whitelisting allowed problem types. This change ensures that only known and safe configuration modules can be loaded via convert_nested_dictionary_to_cfg_base.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull Request addresses the issue of unvalidated dynamic module imports in the configuration loader, as discussed in #972.
The implementation in
llm_studio/src/utils/config_utils.pycurrently utilizes theproblem_typefield to dynamically construct module paths forimportlib.import_module. While the risk of arbitrary code execution is minimal, this pattern can lead to unintended module loading or unexpected runtime behavior.Validation against the predefined
GENERATION_PROBLEM_TYPESandNON_GENERATION_PROBLEM_TYPESallowlists has been introduced before any module load occurs. This refactor ensures only validated configuration modules are imported, improving the stability of the loader.Summary of Changes:
convert_nested_dictionary_to_cfg_baseto checkproblem_typeagainst an allowlist.text_sequence_to_sequence_modelingto the allowlist.NotImplementedErrorfor unsupported or unvalidated problem types.Verified the fix with local testing and confirmed
make formatpasses.Closes #972