{"id":19,"date":"2024-11-25T16:58:47","date_gmt":"2024-11-25T13:58:47","guid":{"rendered":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/?p=19"},"modified":"2024-11-25T18:08:58","modified_gmt":"2024-11-25T15:08:58","slug":"sql-injection-how-it-works-leila-alves","status":"publish","type":"post","link":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/2024\/11\/25\/sql-injection-how-it-works-leila-alves\/","title":{"rendered":"SQL injection: How It Works Leila Alves"},"content":{"rendered":"<div class=\"eq er es et eu l\">\n<article>\n<div class=\"l\">\n<div class=\"l\">\n<section>\n<div>\n<div class=\"fj fk fl fm fn\">\n<div class=\"ab cb\">\n<div class=\"ci bh ev ew ex ey\">\n<figure class=\"lj lk ll lm ln lo lg lh paragraph-image\">\n<div class=\"lp lq ed lr bh ls\" role=\"button\">\n<div class=\"lg lh li\"><img loading=\"lazy\" decoding=\"async\" class=\"bh ko lt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:933\/0*uVkA3GVawt-kX_hN\" alt=\"\" width=\"700\" height=\"1050\" \/><\/div>\n<\/div><figcaption class=\"lu lv lw lg lh lx ly bf b bg z dx\" data-selectable-paragraph=\"\">Photo by\u00a0<a class=\"af lz\" href=\"https:\/\/unsplash.com\/@kevcostello?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Kev Costello<\/a>\u00a0on\u00a0<a class=\"af lz\" href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Unsplash<\/a><\/figcaption><\/figure>\n<p id=\"65b7\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\">SQL injection is a type of web attack that allows attackers to inject malicious SQL code into an application\u2019s database queries. This can be done by exploiting vulnerabilities in the application\u2019s input validation process. Once the attacker\u2019s code is executed, they can gain unauthorized access to sensitive data, modify or delete data, or even take control of the database server.<\/p>\n<h2 id=\"3ce6\" class=\"my mz fq bf na nb nc nd ne nf ng nh ni ml nj nk nl mp nm nn no mt np nq nr ns bk\" data-selectable-paragraph=\"\">How SQL injection works:<\/h2>\n<p id=\"aea5\" class=\"pw-post-body-paragraph ma mb fq mc b md nt mf mg mh nu mj mk ml nv mn mo mp nw mr ms mt nx mv mw mx fj bk\" data-selectable-paragraph=\"\">SQL injection attacks typically work in one of two ways:<\/p>\n<blockquote class=\"ny nz oa\">\n<p id=\"4f54\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">In-band SQL injection:<\/strong>\u00a0The attacker injects malicious SQL code into a form field or other input field that is processed by the application. The application then executes the code without properly validating it, which allows the attacker to gain access to the database.<\/p>\n<p id=\"ef69\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">Out-of-band SQL injection:<\/strong>\u00a0The attacker injects malicious SQL code into a form field or other input field that is processed by the application. The application then executes the code and returns the results to the attacker through a different channel, such as an email address or a web page.<\/p>\n<\/blockquote>\n<p id=\"0954\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">Impact of SQL injection attacks:<\/strong><\/p>\n<p id=\"a093\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\">SQL injection attacks can have a devastating impact on web applications. Attackers can use SQL injection to:<\/p>\n<blockquote class=\"ny nz oa\">\n<p id=\"ffc8\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\">Steal sensitive data, such as usernames, passwords, credit card numbers, and social security numbers.<\/p>\n<p id=\"6eb9\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\">Modify or delete data, which can cause disruptions to the application\u2019s functionality.<\/p>\n<p id=\"8be4\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\">Take control of the database server, which can give the attacker complete access to all of the data in the database.<\/p>\n<\/blockquote>\n<p id=\"981c\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">Protecting against SQL injection attacks:<\/strong><\/p>\n<p id=\"f0df\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\">There are a number of things that web developers can do to protect their applications from SQL injection attacks, including:<\/p>\n<blockquote class=\"ny nz oa\">\n<p id=\"8b83\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">Validate all user input:<\/strong>\u00a0Before executing any database queries, the application should validate all user input to ensure that it is safe. This can be done using a variety of techniques, such as regular expressions and whitelists.<\/p>\n<p id=\"03d1\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">Use parameterized queries:\u00a0<\/strong>Parameterized queries allow developers to separate the SQL code from the user input. This helps to prevent attackers from injecting malicious code into the SQL queries.<\/p>\n<p id=\"6807\" class=\"ma mb ob mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">Keep software up to date:<\/strong>\u00a0Software vendors regularly release security patches to fix known vulnerabilities. Web developers should make sure to install all security patches as soon as they are available.<\/p>\n<\/blockquote>\n<h2 id=\"60ef\" class=\"my mz fq bf na nb nc nd ne nf ng nh ni ml nj nk nl mp nm nn no mt np nq nr ns bk\" data-selectable-paragraph=\"\"><strong class=\"al\">Note:<\/strong><\/h2>\n<p id=\"5b76\" class=\"pw-post-body-paragraph ma mb fq mc b md nt mf mg mh nu mj mk ml nv mn mo mp nw mr ms mt nx mv mw mx fj bk\" data-selectable-paragraph=\"\">If you are a web developer, please make sure that you are taking the necessary precautions to protect your applications from SQL injection attacks. This includes validating all user input, using parameterized queries, and keeping your software up to date.<\/p>\n<p id=\"5654\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><strong class=\"mc fr\">References:<\/strong><\/p>\n<p id=\"1eff\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><a class=\"af lz\" href=\"https:\/\/pwning.owasp-juice.shop\/companion-guide\/latest\/part2\/injection.html\" target=\"_blank\" rel=\"noopener ugc nofollow\">https:\/\/pwning.owasp-juice.shop\/companion-guide\/latest\/part2\/injection.html<\/a><\/p>\n<p id=\"ec4c\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><a class=\"af lz\" href=\"https:\/\/owasp.org\/www-community\/Injection_Flaws\" target=\"_blank\" rel=\"noopener ugc nofollow\">https:\/\/owasp.org\/www-community\/Injection_Flaws<\/a><\/p>\n<p id=\"9325\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><a class=\"af lz\" href=\"https:\/\/owasp.org\/www-community\/attacks\/Blind_SQL_Injection\" target=\"_blank\" rel=\"noopener ugc nofollow\">https:\/\/owasp.org\/www-community\/attacks\/Blind_SQL_Injection<\/a><\/p>\n<p id=\"f48c\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><a class=\"af lz\" href=\"https:\/\/wiki.owasp.org\/index.php\/Testing_for_NoSQL_injection\" target=\"_blank\" rel=\"noopener ugc nofollow\">https:\/\/wiki.owasp.org\/index.php\/Testing_for_NoSQL_injection<\/a><\/p>\n<p id=\"c3c2\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><a class=\"af lz\" href=\"https:\/\/www.us-cert.gov\/ncas\/tips\/ST04-015\" target=\"_blank\" rel=\"noopener ugc nofollow\">https:\/\/www.us-cert.gov\/ncas\/tips\/ST04-015<\/a><\/p>\n<p id=\"a639\" class=\"pw-post-body-paragraph ma mb fq mc b md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx fj bk\" data-selectable-paragraph=\"\"><a class=\"af lz\" href=\"https:\/\/portswigger.net\/kb\/issues\/00101080_server-side-template-injection\" target=\"_blank\" rel=\"noopener ugc nofollow\">https:\/\/portswigger.net\/kb\/issues\/00101080_server-side-template-injection<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n<\/div>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"ab cb\">\n<div class=\"ci bh ev ew ex ey\">\n<div class=\"oc od ab hs\">\n<div class=\"oe ab\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Photo by\u00a0Kev Costello\u00a0on\u00a0Unsplash SQL injection is a type of web attack that allows attackers to inject malicious SQL code into an application\u2019s database queries. This can be done by exploiting vulnerabilities in the application\u2019s input validation process. Once the attacker\u2019s code is executed, they can gain unauthorized access to sensitive data, modify or delete data, &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/2024\/11\/25\/sql-injection-how-it-works-leila-alves\/\">Continue reading<\/a><\/p>\n","protected":false},"author":55489,"featured_media":103,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-based-attacks","item-wrap"],"_links":{"self":[{"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/users\/55489"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/media\/103"}],"wp:attachment":[{"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.e-me-4all.eu\/GiorgosNic\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}