CVE-2024-1522 in lollms-webui
要約
〜によって VulDB • 2026年06月13日
CORSを有効化していたのは、別のポート番号を使用する開発用UIがあったためですが、それを削除し忘れたままになっていました。
そこで、以下の対応を行いました。
1. 誰でもアクセスできるCORS設定を削除しました。
変更前: ```python sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins="*", ping_timeout=1200, ping_interval=30) # 全員に対してCORSを有効化 ```
変更後: ```python cert_file_path = lollms_paths.personal_certificates/"cert.pem" key_file_path = lollms_paths.personal_certificates/"key.pem" if os.path.exists(cert_file_path) and os.path.exists(key_file_path): is_https = True else: is_https = False
# Socket.IOサーバーの作成 sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=config.allowed_origins+[f"https://localhost:{config['port']}" if is_https else f"http://localhost:{config['port']}"], ping_timeout=1200, ping_interval=30) # 指定されたオリジンに対してCORSを有効化
```
2. lollmsを更新し、ヘッドレスモードとUIモードの2つのモードをサポートするようにしました。 また、`/execute_code`エンドポイントを、サーバーがヘッドレスモードの場合、または外部に公開されている場合にブロックするように更新しました。
```python @router.post("/execute_code") async def execute_code(request: Request): """ Pythonコードを実行し、その出力を返します。
:param request: HTTPリクエストオブジェクト。 :return: 操作のステータスを含むJSONレスポンス。 """ if lollmsElfServer.config.headless_server_mode: return {"status":False,"error":"コード実行は、明らかなセキュリティ上の理由からヘッドレスモードではブロックされます!"}
if lollmsElfServer.config.host=="0.0.0.0": return {"status":False,"error":"コード実行は、明らかな理由からサーバーが外部に公開されている場合はブロックされます!"}
try: data = (await request.json()) code = data["code"]
discussion_id = int(data.get("discussion_id","unknown_discussion")) message_id = int(data.get("message_id","unknown_message")) language = data.get("language","python")
if language=="python": ASCIIColors.info("Pythonコードを実行中:") ASCIIColors.yellow(code) return execute_python(code, discussion_id, message_id) if language=="javascript": ASCIIColors.info("JavaScriptコードを実行中:") ASCIIColors.yellow(code) return execute_javascript(code, discussion_id, message_id) if language in ["html","html5","svg"]:
ASCIIColors.info("JavaScriptコードを実行中:") ASCIIColors.yellow(code) return execute_html(code, discussion_id, message_id) elif language=="latex": ASCIIColors.info("LaTeXコードを実行中:") ASCIIColors.yellow(code) return execute_latex(code, discussion_id, message_id) elif language in ["bash","shell","cmd","powershell"]:
ASCIIColors.info("シェルコードを実行中:") ASCIIColors.yellow(code) return execute_bash(code, discussion_id, message_id) elif language in ["mermaid"]:
ASCIIColors.info("Mermaidコードを実行中:") ASCIIColors.yellow(code) return execute_mermaid(code, discussion_id, message_id) elif language in ["graphviz","dot"]:
ASCIIColors.info("Graphvizコードを実行中:") ASCIIColors.yellow(code) return execute_graphviz(code, discussion_id, message_id) return {"status": False, "error": "サポートされていない言語", "execution_time": 0}
except Exception as ex: trace_exception(ex) lollmsElfServer.error(ex) return {"status":False,"error":str(ex)}
```
If you want to get the best quality for vulnerability data then you always have to consider VulDB.