mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(router): smart routers and per-member rate limits (#9)
Add smart routers: virtual models that score each request and route it to admin-defined model tiers. A retryable failure moves the request to a higher tier. The classifier v2 extracts prose, finds the original ask in long tool loops, adds an uncertainty margin and reads tool-output failures. Sessions, outcome signals, bounded calibration, adaptive selection within a tier, gated saturation downgrade, a first-byte timeout and an opt-in timeout fallback are included. Every new feature is off by default. Add per-member group limits, a tokensPerMinute window that counts uncached input and output, rate-limit headers in three dialects, soft pacing before the hard limit, and a limitExemptKinds list so embedding and reranking traffic never counts toward or hits a limit. Fix yaegi named-result state that made smartContentSize grow between calls.
This commit is contained in:
+128
@@ -0,0 +1,128 @@
|
||||
[
|
||||
{
|
||||
"id": "h2-s01",
|
||||
"group": "security",
|
||||
"lang": "en",
|
||||
"intent": "security",
|
||||
"wire": "openai",
|
||||
"request": {
|
||||
"model": "smart/auto",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "review this endpoint for security problems\n\n```py\[email protected]('/download')\ndef dl():\n name = request.args['f']\n return send_file('/srv/files/' + name)\n```"
|
||||
}
|
||||
]
|
||||
},
|
||||
"session": null,
|
||||
"minTier": 0,
|
||||
"maxTier": 1,
|
||||
"notes": "obvious path traversal"
|
||||
},
|
||||
{
|
||||
"id": "h2-s02",
|
||||
"group": "security",
|
||||
"lang": "en",
|
||||
"intent": "security",
|
||||
"wire": "openai",
|
||||
"request": {
|
||||
"model": "smart/auto",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "is it safe to store jwt in localStorage"
|
||||
}
|
||||
]
|
||||
},
|
||||
"session": null,
|
||||
"minTier": 0,
|
||||
"maxTier": 1,
|
||||
"notes": "well-known tradeoff"
|
||||
},
|
||||
{
|
||||
"id": "h2-s03",
|
||||
"group": "security",
|
||||
"lang": "en",
|
||||
"intent": "security",
|
||||
"wire": "anthropic",
|
||||
"request": {
|
||||
"model": "smart/auto",
|
||||
"max_tokens": 4096,
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "we verify webhook sigs with `if sig == hmac(secret, body).hexdigest()`. pen tester flagged it medium. we compare as strings, whats the real attack and is it exploitable over the internet through our cloudflare->nginx->app path?"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"session": null,
|
||||
"minTier": 1,
|
||||
"maxTier": 2,
|
||||
"notes": "timing attack practicality discussion; nuanced"
|
||||
},
|
||||
{
|
||||
"id": "h2-s04",
|
||||
"group": "security",
|
||||
"lang": "en",
|
||||
"intent": "security",
|
||||
"wire": "openai",
|
||||
"request": {
|
||||
"model": "smart/auto",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "audit this oauth redirect handler, there's something off but i can't see it\n\n```js\napp.get('/cb', (req,res)=>{\n const next = req.query.next || '/';\n if (next.startsWith('/') ) return res.redirect(next);\n res.redirect('/');\n});\n```"
|
||||
}
|
||||
]
|
||||
},
|
||||
"session": null,
|
||||
"minTier": 1,
|
||||
"maxTier": 2,
|
||||
"notes": "`//evil.com` and `/\\evil.com` open redirect bypass; subtle but classic"
|
||||
},
|
||||
{
|
||||
"id": "h2-s05",
|
||||
"group": "security",
|
||||
"lang": "en",
|
||||
"intent": "security",
|
||||
"wire": "openai",
|
||||
"request": {
|
||||
"model": "smart/auto",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "what does `chmod 777` do and why do people say its bad"
|
||||
}
|
||||
]
|
||||
},
|
||||
"session": null,
|
||||
"minTier": 0,
|
||||
"maxTier": 0,
|
||||
"notes": "basic"
|
||||
},
|
||||
{
|
||||
"id": "h2-s06",
|
||||
"group": "security",
|
||||
"lang": "en",
|
||||
"intent": "security",
|
||||
"wire": "openai",
|
||||
"request": {
|
||||
"model": "smart/auto",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "We deserialize user-supplied YAML with `yaml.load(data)` in a PyYAML 5.x service behind auth, and the same service signs JWTs with a key in env. Assess realistic impact and order of mitigation."
|
||||
}
|
||||
]
|
||||
},
|
||||
"session": null,
|
||||
"minTier": 1,
|
||||
"maxTier": 2,
|
||||
"notes": "RCE via unsafe load + secret access chain; mid can do"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user