You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "luarx (via GitHub)" <gi...@apache.org> on 2025/06/12 11:11:05 UTC
[I] bug: APISIX does not respect updated plugin priorities when using the CORS and limit-count plugins [apisix]
luarx opened a new issue, #12321:
URL: https://github.com/apache/apisix/issues/12321
### Current Behavior
OPTIONS requests are not being rate-limited by the limit-count plugin when the CORS plugin is also configured, even when the limit-count plugin is assigned a higher priority
I have checked and CORS plugin has more priority than limit-count:
- CORS: [4000](https://github.com/apache/apisix/blob/master/apisix/plugins/cors.lua#L149)
- limit-count: [1002](https://github.com/apache/apisix/blob/master/apisix/plugins/limit-count.lua#L24)
But specifying a custom priority for each plugin should prioritise limit-count over CORS
### Expected Behavior
I want OPTIONS requests (preflight CORS headers) to be rate-limited when using CORS plugin when specifying custom priorities.
This is to prevent some DDoS attacks
### Error Logs
_No response_
### Steps to Reproduce
Configure this route
{
"uris": [
"/example/*"
],
"name": "example",
"methods": [
"OPTIONS"
],
"plugins": {
"cors": {
"_meta": {
"priority": 20
},
"allow_credential": false,
"allow_headers": "*",
"allow_methods": "*",
"allow_origins": "*",
"max_age": 5
},
"limit-count": {
"_meta": {
"priority": 5000
},
"allow_degradation": false,
"count": 5,
"key": "remote_addr",
"key_type": "var",
"policy": "local",
"rejected_code": 429,
"show_limit_quota_header": true,
"time_window": 1
}
},
"upstream_id": "1e7e3c71",
"status": 1
}
### Environment
- APISIX version (run `apisix version`): v3.12.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: APISIX does not respect updated plugin priorities when using the CORS and limit-count plugins [apisix]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #12321:
URL: https://github.com/apache/apisix/issues/12321#issuecomment-2968798853
This is expected behavior:
1. The CORS plugin is implemented in the rewrite phase: it returns a 200 status code directly when processing OPTIONS requests.
2. The limit-count plugin is executed in the access stage, and performs limit-count checking.
3. Phase execution order: rewrite → access → content
4. Early termination: The CORS plugin returns a response in the rewrite phase, causing request processing to end early and skipping the access phase.
The response to an options request is generated and returned directly by APISIX and does not reach upstream, so what is the problem?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: APISIX does not respect updated plugin priorities when using the CORS and limit-count plugins [apisix]
Posted by "luarx (via GitHub)" <gi...@apache.org>.
luarx commented on issue #12321:
URL: https://github.com/apache/apisix/issues/12321#issuecomment-2969583848
Oh great, that a lot for taking your time explaining that, now it is clearer why "priorities" are not working in this case 🙌
> The response to an options request is generated and returned directly by APISIX and does not reach upstream, so what is the problem?
I was worried about rate-limiting OPTIONS requests because of some kind of attack.
On the other hand, as you mentioned, those requests do not reach any upstream when using CORS plugin (different case would be if not using CORS plugin) so the only piece that could be overloaded during a DDoS attack would be Apisix, and to protect that a different layer/component would be needed 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: APISIX does not respect updated plugin priorities when using the CORS and limit-count plugins [apisix]
Posted by "luarx (via GitHub)" <gi...@apache.org>.
luarx commented on issue #12321:
URL: https://github.com/apache/apisix/issues/12321#issuecomment-2969590112
Oh great, that a lot for taking your time explaining that, now it is clearer why "priorities" are not working in this case 🙌
The response to an options request is generated and returned directly by APISIX and does not reach upstream, so what is the problem?
I was worried about rate-limiting OPTIONS requests because of some kind of attack.
On the other hand, as you mentioned, those requests do not reach any upstream when using CORS plugin (different case would be if not using CORS plugin) so the only piece that could be overloaded during a DDoS attack would be Apisix, and to protect that a different layer/component would be needed 👍
I will close this as it is clarified
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: APISIX does not respect updated plugin priorities when using the CORS and limit-count plugins [apisix]
Posted by "luarx (via GitHub)" <gi...@apache.org>.
luarx closed issue #12321: bug: APISIX does not respect updated plugin priorities when using the CORS and limit-count plugins
URL: https://github.com/apache/apisix/issues/12321
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org