Limit amount of parameters in query string

chrisbrez

I just want to limit the amount of parameters that nginx/apache allows to pass. For example: if someone tries to access a link like test.php?arg1=value&arg2=value&arg3=value give them a 404 error or 403 it doesn't matter. If the URL contains more than two arguments/parameters it should be blocked by the webserver. Is there a way to achieve this task ? I've tried something for Apache htaccess but with no success. I'm talking about limiting the amount of parameters for the entire website not just one page/file.

RewriteCond %{QUERY_STRING} (([a-z]+){3,})=(.*) [NC]
RewriteRule (.*) /404.php? [R=404,L]

Can this thing be done for Apache and Nginx ?

Richard Smith

A simplistic approach would be to limit the number of & characters in the $args string.

If there are only two parameters, there is usually only one & to join them, so the sequence &.*& should not exist.

For example:

if ($args ~ "&.*&") { return 403; }

See this caution on the use of if.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to limit the amount of characters in a Lua string

分類Dev

How To Limit The Amount Of Notifications

分類Dev

How to implement query string parameters for RESTful APIs

分類Dev

Regex for URL rewrite with optional query string parameters

分類Dev

Dynamic database requests without query string parameters

分類Dev

Converting a query parameters string into a regex expression

分類Dev

LIMIT amount of rows fetched by JOIN

分類Dev

Math.abs() Limit the amount of deimals

分類Dev

How to limit the amount of bullets in a JavaScript Game?

分類Dev

REST API plugin - use body instead of query string for parameters

分類Dev

passing optional query string parameters to http service call

分類Dev

Getting parameters from query string in Zend Framework 2.3

分類Dev

Android SearchRecentSuggestionsProvider query limit

分類Dev

Over Query limit

分類Dev

LIMIT not working on complex query

分類Dev

Android Retrofit: URL query string "text={userInput}&key={apiKey}" must not have replace block. For dynamic query parameters use @Query

分類Dev

How to limit amount of pods with attached managed disks per node

分類Dev

Limit the amount of times font size can be increased and decreased

分類Dev

Django Query: How to order posts by amount of upvotes?

分類Dev

Parse "or" query with limit returns all records ignoring limit on single query

分類Dev

Cypher query limit results and delete

分類Dev

Ruby on Rails query limit in a range

分類Dev

Parse query parameters with regexp

分類Dev

Use parameters for MySqlCommand query

分類Dev

How can I get the right day of the week, if I am setting the date in relation to the given query string parameters?

分類Dev

IIS 7 rewrite rule - rewrite same page, one or multiple query string parameters

分類Dev

Laravel Eloquent query with optional parameters

分類Dev

301 redirect with query parameters and ~ in URL

分類Dev

JpaRepository native query not detecting parameters

Related 関連記事

  1. 1

    How to limit the amount of characters in a Lua string

  2. 2

    How To Limit The Amount Of Notifications

  3. 3

    How to implement query string parameters for RESTful APIs

  4. 4

    Regex for URL rewrite with optional query string parameters

  5. 5

    Dynamic database requests without query string parameters

  6. 6

    Converting a query parameters string into a regex expression

  7. 7

    LIMIT amount of rows fetched by JOIN

  8. 8

    Math.abs() Limit the amount of deimals

  9. 9

    How to limit the amount of bullets in a JavaScript Game?

  10. 10

    REST API plugin - use body instead of query string for parameters

  11. 11

    passing optional query string parameters to http service call

  12. 12

    Getting parameters from query string in Zend Framework 2.3

  13. 13

    Android SearchRecentSuggestionsProvider query limit

  14. 14

    Over Query limit

  15. 15

    LIMIT not working on complex query

  16. 16

    Android Retrofit: URL query string "text={userInput}&key={apiKey}" must not have replace block. For dynamic query parameters use @Query

  17. 17

    How to limit amount of pods with attached managed disks per node

  18. 18

    Limit the amount of times font size can be increased and decreased

  19. 19

    Django Query: How to order posts by amount of upvotes?

  20. 20

    Parse "or" query with limit returns all records ignoring limit on single query

  21. 21

    Cypher query limit results and delete

  22. 22

    Ruby on Rails query limit in a range

  23. 23

    Parse query parameters with regexp

  24. 24

    Use parameters for MySqlCommand query

  25. 25

    How can I get the right day of the week, if I am setting the date in relation to the given query string parameters?

  26. 26

    IIS 7 rewrite rule - rewrite same page, one or multiple query string parameters

  27. 27

    Laravel Eloquent query with optional parameters

  28. 28

    301 redirect with query parameters and ~ in URL

  29. 29

    JpaRepository native query not detecting parameters

ホットタグ

アーカイブ