Skip to content

[Bug]: Security checks too strict for custom handlers #11009

@JohnPaton

Description

@JohnPaton

What happened?

If you pass the path to a custom handler and it contains the substring os anywhere, the handler will fail to load "for security reasons". This is very prone to false positives, e.g. having your handler in a directory tree containing git_repos will trigger it.

Example for having a directory in the tree called tempos below:

litellm_settings:
  custom_provider_map:
  - custom_handler: /Users/jpaton/temp/tempos/test-litellm-proxy/my_llm.my_llm

yields

ERROR:    Traceback (most recent call last):
  File "/Users/jpaton/temp/tempos/test-litellm-proxy/.venv/lib/python3.12/site-packages/litellm/proxy/types_utils/utils.py", line 18, in get_instance_fn
    security_checks(module_name=module_name)
  File "/Users/jpaton/temp/tempos/test-litellm-proxy/.venv/lib/python3.12/site-packages/litellm/proxy/types_utils/utils.py", line 77, in security_checks
    raise ImportError(
ImportError: Importing from module /Users/jpaton/temp/tempos/test-litellm-proxy/my_llm is not allowed for security reasons

The checks were introduced in 441c727

Relevant log output

Are you a ML Ops Team?

Yes

What LiteLLM version are you on ?

1.69.2

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions