waf_condition_string_match.tf 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. resource "aws_wafregional_byte_match_set" "match_admin_url" {
  2. name = "${var.waf_prefix}-generic-match-admin-url"
  3. byte_match_tuples {
  4. text_transformation = "URL_DECODE"
  5. target_string = "/admin"
  6. positional_constraint = "STARTS_WITH"
  7. field_to_match {
  8. type = "URI"
  9. }
  10. }
  11. }
  12. resource "aws_wafregional_byte_match_set" "match_saml_url" {
  13. name = "${var.waf_prefix}-generic-match-saml-url"
  14. byte_match_tuples {
  15. text_transformation = "URL_DECODE"
  16. target_string = "/complete/saml"
  17. positional_constraint = "STARTS_WITH"
  18. field_to_match {
  19. type = "URI"
  20. }
  21. }
  22. }
  23. resource "aws_wafregional_byte_match_set" "match_admin_company_url" {
  24. name = "${var.waf_prefix}-generic-match-admin-company-url"
  25. byte_match_tuples {
  26. text_transformation = "URL_DECODE"
  27. target_string = "/admin/user_portal/company/"
  28. positional_constraint = "STARTS_WITH"
  29. field_to_match {
  30. type = "URI"
  31. }
  32. }
  33. }
  34. resource "aws_wafregional_byte_match_set" "match_api_url" {
  35. name = "${var.waf_prefix}-generic-match-api-url"
  36. byte_match_tuples {
  37. text_transformation = "URL_DECODE"
  38. target_string = "/api/"
  39. positional_constraint = "STARTS_WITH"
  40. field_to_match {
  41. type = "URI"
  42. }
  43. }
  44. }
  45. resource "aws_wafregional_byte_match_set" "match_login_url" {
  46. name = "${var.waf_prefix}-generic-match-login-url"
  47. byte_match_tuples {
  48. text_transformation = "URL_DECODE"
  49. target_string = "/login"
  50. positional_constraint = "STARTS_WITH"
  51. field_to_match {
  52. type = "URI"
  53. }
  54. }
  55. }
  56. resource "aws_wafregional_byte_match_set" "match_auth_tokens" {
  57. name = "${var.waf_prefix}-generic-match-auth-tokens"
  58. byte_match_tuples {
  59. text_transformation = "URL_DECODE"
  60. target_string = ".TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"
  61. positional_constraint = "ENDS_WITH"
  62. field_to_match {
  63. type = "HEADER"
  64. data = "authorization"
  65. }
  66. }
  67. byte_match_tuples {
  68. text_transformation = "URL_DECODE"
  69. target_string = "example-session-id"
  70. positional_constraint = "CONTAINS"
  71. field_to_match {
  72. type = "HEADER"
  73. data = "cookie"
  74. }
  75. }
  76. }
  77. resource "aws_wafregional_byte_match_set" "match_csrf_method" {
  78. name = "${var.waf_prefix}-generic-match-csrf-method"
  79. byte_match_tuples {
  80. text_transformation = "LOWERCASE"
  81. target_string = "post"
  82. positional_constraint = "EXACTLY"
  83. field_to_match {
  84. type = "METHOD"
  85. }
  86. }
  87. }
  88. resource "aws_wafregional_byte_match_set" "match_php_insecure_uri" {
  89. name = "${var.waf_prefix}-generic-match-php-insecure-uri"
  90. byte_match_tuples {
  91. text_transformation = "URL_DECODE"
  92. target_string = "php"
  93. positional_constraint = "ENDS_WITH"
  94. field_to_match {
  95. type = "URI"
  96. }
  97. }
  98. byte_match_tuples {
  99. text_transformation = "URL_DECODE"
  100. target_string = "/"
  101. positional_constraint = "ENDS_WITH"
  102. field_to_match {
  103. type = "URI"
  104. }
  105. }
  106. }
  107. resource "aws_wafregional_byte_match_set" "match_php_insecure_var_refs" {
  108. name = "${var.waf_prefix}-generic-match-php-insecure-var-refs"
  109. byte_match_tuples {
  110. text_transformation = "URL_DECODE"
  111. target_string = "_ENV["
  112. positional_constraint = "CONTAINS"
  113. field_to_match {
  114. type = "QUERY_STRING"
  115. }
  116. }
  117. byte_match_tuples {
  118. text_transformation = "URL_DECODE"
  119. target_string = "auto_append_file="
  120. positional_constraint = "CONTAINS"
  121. field_to_match {
  122. type = "QUERY_STRING"
  123. }
  124. }
  125. byte_match_tuples {
  126. text_transformation = "URL_DECODE"
  127. target_string = "disable_functions="
  128. positional_constraint = "CONTAINS"
  129. field_to_match {
  130. type = "QUERY_STRING"
  131. }
  132. }
  133. byte_match_tuples {
  134. text_transformation = "URL_DECODE"
  135. target_string = "auto_prepend_file="
  136. positional_constraint = "CONTAINS"
  137. field_to_match {
  138. type = "QUERY_STRING"
  139. }
  140. }
  141. byte_match_tuples {
  142. text_transformation = "URL_DECODE"
  143. target_string = "safe_mode="
  144. positional_constraint = "CONTAINS"
  145. field_to_match {
  146. type = "QUERY_STRING"
  147. }
  148. }
  149. byte_match_tuples {
  150. text_transformation = "URL_DECODE"
  151. target_string = "_SERVER["
  152. positional_constraint = "CONTAINS"
  153. field_to_match {
  154. type = "QUERY_STRING"
  155. }
  156. }
  157. byte_match_tuples {
  158. text_transformation = "URL_DECODE"
  159. target_string = "allow_url_include="
  160. positional_constraint = "CONTAINS"
  161. field_to_match {
  162. type = "QUERY_STRING"
  163. }
  164. }
  165. byte_match_tuples {
  166. text_transformation = "URL_DECODE"
  167. target_string = "open_basedir="
  168. positional_constraint = "CONTAINS"
  169. field_to_match {
  170. type = "QUERY_STRING"
  171. }
  172. }
  173. }
  174. resource "aws_wafregional_byte_match_set" "match_rfi_lfi_traversal" {
  175. name = "${var.waf_prefix}-generic-match-rfi-lfi-traversal"
  176. byte_match_tuples {
  177. text_transformation = "HTML_ENTITY_DECODE"
  178. target_string = "://"
  179. positional_constraint = "CONTAINS"
  180. field_to_match {
  181. type = "QUERY_STRING"
  182. }
  183. }
  184. byte_match_tuples {
  185. text_transformation = "HTML_ENTITY_DECODE"
  186. target_string = "../"
  187. positional_constraint = "CONTAINS"
  188. field_to_match {
  189. type = "QUERY_STRING"
  190. }
  191. }
  192. byte_match_tuples {
  193. text_transformation = "URL_DECODE"
  194. target_string = "://"
  195. positional_constraint = "CONTAINS"
  196. field_to_match {
  197. type = "QUERY_STRING"
  198. }
  199. }
  200. byte_match_tuples {
  201. text_transformation = "URL_DECODE"
  202. target_string = "../"
  203. positional_constraint = "CONTAINS"
  204. field_to_match {
  205. type = "QUERY_STRING"
  206. }
  207. }
  208. byte_match_tuples {
  209. text_transformation = "HTML_ENTITY_DECODE"
  210. target_string = "://"
  211. positional_constraint = "CONTAINS"
  212. field_to_match {
  213. type = "URI"
  214. }
  215. }
  216. byte_match_tuples {
  217. text_transformation = "HTML_ENTITY_DECODE"
  218. target_string = "../"
  219. positional_constraint = "CONTAINS"
  220. field_to_match {
  221. type = "URI"
  222. }
  223. }
  224. byte_match_tuples {
  225. text_transformation = "URL_DECODE"
  226. target_string = "://"
  227. positional_constraint = "CONTAINS"
  228. field_to_match {
  229. type = "URI"
  230. }
  231. }
  232. byte_match_tuples {
  233. text_transformation = "URL_DECODE"
  234. target_string = "../"
  235. positional_constraint = "CONTAINS"
  236. field_to_match {
  237. type = "URI"
  238. }
  239. }
  240. }
  241. resource "aws_wafregional_byte_match_set" "match_ssi" {
  242. name = "${var.waf_prefix}-generic-match-ssi"
  243. byte_match_tuples {
  244. text_transformation = "LOWERCASE"
  245. target_string = ".cfg"
  246. positional_constraint = "ENDS_WITH"
  247. field_to_match {
  248. type = "URI"
  249. }
  250. }
  251. byte_match_tuples {
  252. text_transformation = "LOWERCASE"
  253. target_string = ".backup"
  254. positional_constraint = "ENDS_WITH"
  255. field_to_match {
  256. type = "URI"
  257. }
  258. }
  259. byte_match_tuples {
  260. text_transformation = "LOWERCASE"
  261. target_string = ".ini"
  262. positional_constraint = "ENDS_WITH"
  263. field_to_match {
  264. type = "URI"
  265. }
  266. }
  267. byte_match_tuples {
  268. text_transformation = "LOWERCASE"
  269. target_string = ".conf"
  270. positional_constraint = "ENDS_WITH"
  271. field_to_match {
  272. type = "URI"
  273. }
  274. }
  275. byte_match_tuples {
  276. text_transformation = "LOWERCASE"
  277. target_string = ".log"
  278. positional_constraint = "ENDS_WITH"
  279. field_to_match {
  280. type = "URI"
  281. }
  282. }
  283. byte_match_tuples {
  284. text_transformation = "LOWERCASE"
  285. target_string = ".bak"
  286. positional_constraint = "ENDS_WITH"
  287. field_to_match {
  288. type = "URI"
  289. }
  290. }
  291. byte_match_tuples {
  292. text_transformation = "LOWERCASE"
  293. target_string = ".config"
  294. positional_constraint = "ENDS_WITH"
  295. field_to_match {
  296. type = "URI"
  297. }
  298. }
  299. byte_match_tuples {
  300. text_transformation = "URL_DECODE"
  301. target_string = "/includes"
  302. positional_constraint = "STARTS_WITH"
  303. field_to_match {
  304. type = "URI"
  305. }
  306. }
  307. }