mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-18 22:30:40 -07:00
fix: harden voice prompt cache loading and SPA path guard (#429)
Two small safety improvements: 1. Voice prompt cache (cache.py): add weights_only=True to torch.load() so cached .prompt files are loaded using the safe unpickler instead of the unrestricted pickle deserializer. This follows the PyTorch 2.6+ best practice of opting in to safe loading for all torch.load() calls. 2. SPA catch-all (app.py): replace str.startswith() path guard with Path.is_relative_to(). The string prefix check passes for sibling paths like /app/frontend_evil/ that share the /app/frontend prefix. is_relative_to() correctly tests directory containment.
This commit is contained in:
@@ -64,7 +64,7 @@ def get_cached_voice_prompt(
|
||||
cache_file = _get_cache_dir() / f"{cache_key}.prompt"
|
||||
if cache_file.exists():
|
||||
try:
|
||||
prompt = torch.load(cache_file)
|
||||
prompt = torch.load(cache_file, weights_only=True)
|
||||
_memory_cache[cache_key] = prompt
|
||||
return prompt
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user