You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FileBaseTinyExpressionInstancesCache: resolve tenant paths strictly
under the configured rootFolder. Any TenantID implementation whose
asString() returns traversal sequences (../, absolute paths) is now
rejected before opening the file, so a custom TenantID cannot escape
the formula root directory.
McpServer: replace unbounded readAllBytes() with a 16 MiB cap on both
the Content-Length header and the actual stream read, returning 413
when exceeded. Prevents OOM from huge POST bodies on the 0.0.0.0-bound
HTTP listener.
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
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.
背景
セキュリティ観点の横断確認で見つかった、再現経路が成立する2件を修正。
修正1: パストラバーサル (FileBaseTinyExpressionInstancesCache)
instances/FileBaseTinyExpressionInstancesCache.javaはrootFolder.resolve(tenantId.asString())でテナント別のformulaInfo.txtを開く。TenantIDは interface でasString()の override を許すため、"../../etc"や"/etc"を返す実装を渡すと root 配下を脱出できる。再現手順:
TenantIDを独自実装しasString()が"../../etc"を返すようにするnew FileBaseTinyExpressionInstancesCache(rootPath, fields).cache(tenantId, ...)を呼ぶrootPath配下ではなくrootPathの親方向のパスが開かれる修正:
resolveUnderRootでrootFolder.toAbsolutePath().normalize()配下に制限し、脱出する場合はIllegalArgumentExceptionで拒否。修正2: MCP リクエストbodyの無制限読み込み (McpServer)
mcp/McpServer.javaのreadBodyはis.readAllBytes()で無制限に読み込む。サーバは0.0.0.0にバインドされるため、ネットワークから巨大 POST を送ると OOM。再現手順:
McpServerを起動(既定ポート 9237)curl -X POST http://host:9237/mcp --data-binary @/dev/zeroのように巨大 body を送信readAllBytes()でヒープを消費し OOM修正:
Content-Lengthヘッダと実際の読み込みを 16 MiB(MAX_REQUEST_BODY_BYTES)で制限。超過時は 413 を返す。テスト
FileBaseTinyExpressionInstancesCacheTest: 通常 acceptance / traversal 拒否 / 絶対パス拒否 / null root 拒否 の4件McpServerTest#oversizedBody_rejectedWith413: 上限超過で 413 が返ることを確認TinyExpressionsExecutorTest,FormulaInfoParserTest,McpServerTest全通過範囲外(別 issue で起票)
0.0.0.0バインド + 認証なしは破壊的判断が必要なため別 issue で扱う