Mitigate litellm supply chain compromise (1.82.7, 1.82.8)#393
Mitigate litellm supply chain compromise (1.82.7, 1.82.8)#393TomasTomecek merged 2 commits intopackit:mainfrom
Conversation
litellm 1.82.7 and 1.82.8 were supply-chain-compromised packages containing a malicious .pth file that executes at Python startup and exfiltrates credentials (SSH keys, cloud creds, kubeconfigs). litellm is a transitive dependency via beeai-framework, which allows >=1.76.1,<2.0.0, so pip could resolve to either bad version. See: BerriAI/litellm#24512 Signed-off-by: Tomas Tomecek <ttomecek@redhat.com> Assisted-by: Claude
The compromised litellm 1.82.7/1.82.8 packages drop a litellm_init.pth file into site-packages that executes automatically at Python startup. Adding a RUN step after pip install that searches /usr and /opt for this file and fails the build if found provides a defence-in-depth safety net in case the version exclusion is ever bypassed. Signed-off-by: Tomas Tomecek <ttomecek@redhat.com> Assisted-by: Claude
There was a problem hiding this comment.
Code Review
This pull request updates dependency configurations in pyproject.toml and several Containerfiles to exclude specific problematic versions of the litellm library (1.82.7 and 1.82.8). It also introduces a security check in the Containerfiles to detect and prevent the use of malicious litellm_init.pth files. The feedback suggests improving the robustness and clarity of the security alert message, specifically by quoting the $MALICIOUS variable to handle filenames with spaces or multiple results, and by redirecting the output to stderr.
| RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \ | ||
| if [ -n "$MALICIOUS" ]; then \ | ||
| echo "SECURITY ALERT: malicious litellm_init.pth detected: $MALICIOUS"; \ | ||
| exit 1; \ | ||
| fi |
There was a problem hiding this comment.
The error message when a malicious file is found could be improved for clarity and robustness. The current implementation with an unquoted $MALICIOUS variable can lead to garbled output if multiple files are found or if filenames contain spaces. It is also a good practice to redirect error messages to stderr (>&2).
RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \
if [ -n "$MALICIOUS" ]; then \
echo "SECURITY ALERT: malicious litellm_init.pth detected:" >&2; \
echo "$MALICIOUS" >&2; \
exit 1; \
fi
There was a problem hiding this comment.
Thanks Gemini but you are just picking nits here, I'm not applying that to all occurences, sorry
| RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \ | ||
| if [ -n "$MALICIOUS" ]; then \ | ||
| echo "SECURITY ALERT: malicious litellm_init.pth detected: $MALICIOUS"; \ | ||
| exit 1; \ | ||
| fi |
There was a problem hiding this comment.
The error message when a malicious file is found could be improved for clarity and robustness. The current implementation with an unquoted $MALICIOUS variable can lead to garbled output if multiple files are found or if filenames contain spaces. It is also a good practice to redirect error messages to stderr (>&2).
RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \
if [ -n "$MALICIOUS" ]; then \
echo "SECURITY ALERT: malicious litellm_init.pth detected:" >&2; \
echo "$MALICIOUS" >&2; \
exit 1; \
fi
| RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \ | ||
| if [ -n "$MALICIOUS" ]; then \ | ||
| echo "SECURITY ALERT: malicious litellm_init.pth detected: $MALICIOUS"; \ | ||
| exit 1; \ | ||
| fi |
There was a problem hiding this comment.
The error message when a malicious file is found could be improved for clarity and robustness. The current implementation with an unquoted $MALICIOUS variable can lead to garbled output if multiple files are found or if filenames contain spaces. It is also a good practice to redirect error messages to stderr (>&2).
RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \
if [ -n "$MALICIOUS" ]; then \
echo "SECURITY ALERT: malicious litellm_init.pth detected:" >&2; \
echo "$MALICIOUS" >&2; \
exit 1; \
fi
| RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \ | ||
| if [ -n "$MALICIOUS" ]; then \ | ||
| echo "SECURITY ALERT: malicious litellm_init.pth detected: $MALICIOUS"; \ | ||
| exit 1; \ | ||
| fi |
There was a problem hiding this comment.
The error message when a malicious file is found could be improved for clarity and robustness. The current implementation with an unquoted $MALICIOUS variable can lead to garbled output if multiple files are found or if filenames contain spaces. It is also a good practice to redirect error messages to stderr (>&2).
RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \
if [ -n "$MALICIOUS" ]; then \
echo "SECURITY ALERT: malicious litellm_init.pth detected:" >&2; \
echo "$MALICIOUS" >&2; \
exit 1; \
fi
| RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \ | ||
| if [ -n "$MALICIOUS" ]; then \ | ||
| echo "SECURITY ALERT: malicious litellm_init.pth detected: $MALICIOUS"; \ | ||
| exit 1; \ | ||
| fi |
There was a problem hiding this comment.
The error message when a malicious file is found could be improved for clarity and robustness. The current implementation with an unquoted $MALICIOUS variable can lead to garbled output if multiple files are found or if filenames contain spaces. It is also a good practice to redirect error messages to stderr (>&2).
RUN MALICIOUS=$(find /usr /opt -name "litellm_init.pth" 2>/dev/null); \
if [ -n "$MALICIOUS" ]; then \
echo "SECURITY ALERT: malicious litellm_init.pth detected:" >&2; \
echo "$MALICIOUS" >&2; \
exit 1; \
fi
nforro
left a comment
There was a problem hiding this comment.
I think we need a base image 🙂
litellm==1.82.7andlitellm==1.82.8from all Containerfilesand
pyproject.toml— these versions contain a malicious.pthfilethat harvests credentials at Python startup and exfiltrates them via curl
RUNbuild step to every Containerfile that fails the build if themalicious
litellm_init.pthis found in site-packages, as a defence-in-depthsafety net
litellm 1.82.7 and 1.82.8 were supply-chain-compromised packages published
to PyPI. They contain
litellm_init.pth, a.pthfile that executesautomatically when Python starts (no import required). The payload collects
SSH keys, cloud credentials (AWS/GCP/Azure), kubeconfigs, CI/CD secrets,
and shell history, then exfiltrates them AES+RSA encrypted to an attacker-
controlled host.
We pull in litellm transitively via
beeai-framework==0.1.55, whichspecifies
litellm>=1.76.1,<2.0.0— wide enough to resolve to either badversion. PyPI has since yanked both versions (latest safe is 1.82.6), but
the explicit exclusions make the intent clear and guard against any future
re-publication or similar attack.
Ref: BerriAI/litellm#24512