<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Tolga Ünlü</title>
    <description>The latest articles on Forem by Tolga Ünlü (@tolgadevsec).</description>
    <link>https://forem.com/tolgadevsec</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F415231%2F4856a9f9-a67d-4045-ba24-130c1f491cdb.png</url>
      <title>Forem: Tolga Ünlü</title>
      <link>https://forem.com/tolgadevsec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tolgadevsec"/>
    <language>en</language>
    <item>
      <title>Defensive Coding Reloaded: A Guide To Active Web Application Defence</title>
      <dc:creator>Tolga Ünlü</dc:creator>
      <pubDate>Thu, 21 Apr 2022 20:59:23 +0000</pubDate>
      <link>https://forem.com/tolgadevsec/defensive-coding-reloaded-a-guide-to-active-web-application-defence-58el</link>
      <guid>https://forem.com/tolgadevsec/defensive-coding-reloaded-a-guide-to-active-web-application-defence-58el</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/2cilORSrMtE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo&lt;/strong&gt;&lt;br&gt;
The demo application was implemented in the &lt;a href="https://phpsandbox.io/"&gt;PHP Sandbox&lt;/a&gt;, you can find the application &lt;a href="https://phpsandbox.io/n/securi-tay-2022-lightning-talk-demo-zpq8y"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;br&gt;
Here is the list of links to further resources that I originally included in my speaker notes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://appsensor.org/"&gt;OWASP AppSensor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=1imlD1O4HrY"&gt;AppSensor: Real-Time Event Detection and Response&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=XHeM_OizkoQ"&gt;Trapping Hacks with Ensnare&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/Wkp1Ljs9Qz0?t=3320"&gt;OWASP top ten proactive defenses - App Layer Intrusion Detection&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blogs.sap.com/2020/03/16/the-sundew-project-learning-to-pose-scalability-barriers-to-attackers/"&gt;The SunDEW project: learning to pose scalability barriers to attackers&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://labs.f-secure.com/blog/application-level-purple-teaming/"&gt;Application-level Purple Teaming: A case study&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raz0r.name/talks/waf-js-how-to-protect-web-applications-using-javascript/"&gt;Waf.js: How to Protect Web Applications using JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.jerkeby.se/newsletter/posts/risk-aware-applications/"&gt;Risk-aware applications &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/I3pNLB3Cq24"&gt;Defense by numbers: Making Problems for Script Kiddies and Scanner Monkeys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/7nf45ibSTLQ"&gt;Stupid webappsec Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dustri.org/b/playing-with-the-acusensor.html"&gt;Playing with the acusensor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=5dukn9hcy_Q"&gt;Honeytokens: Detecting Attacks to Your Web Apps Using Decoys and Deception &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.loom.com/share/0acab613b14e4baba20694ea73c97662"&gt;Dynamic Go Instrumentation for Production Environments&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.slideshare.net/NicolasVivet2/secure-your-web-application-with-the-new-python-audit-hooks"&gt;Secure your App with the new Python Audit Hooks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=HQxs3xn7tLA"&gt;Whatever happened to attack aware applications?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/NQVVjEo_I3c"&gt;Self-Defending Databases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/jtXLc9e34cI"&gt;Defeating Automated Web Assessment Tools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=5Ee_mWgRRQk"&gt;Security Vulnerabilities Decomposition: Another Way To Look At Vulnerabilities&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=l2a_34lWWVY"&gt;Getting Started with Security Observability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=syymoKlNp3w"&gt;Sinking Your Hooks in Applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=WN_qof7X_pk"&gt;Injecting Security Into Web Apps With Runtime Patching and Context Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=HDeUpPKpEWc"&gt;Hindsight isn’t good enough: LANGSEC helps you take control of your security&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.detectingmalice.com/"&gt;Detecting Malice&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>php</category>
      <category>security</category>
      <category>laravel</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Catching Attackers with Traps</title>
      <dc:creator>Tolga Ünlü</dc:creator>
      <pubDate>Thu, 09 Dec 2021 12:15:21 +0000</pubDate>
      <link>https://forem.com/tolgadevsec/catching-attackers-with-traps-3bmj</link>
      <guid>https://forem.com/tolgadevsec/catching-attackers-with-traps-3bmj</guid>
      <description>&lt;p&gt;Sometimes, a simple &lt;strong&gt;trap&lt;/strong&gt; or &lt;strong&gt;honeytoken&lt;/strong&gt; placed at the right spot in your application can be enough to catch suspicious activity. This &lt;a href="https://www.youtube.com/watch?v=XHeM_OizkoQ"&gt;video&lt;/a&gt; from Shakacon by two Application Security Engineers at Netflix is an example implementing this idea with a project called &lt;a href="https://github.com/ahoernecke/ensnare"&gt;Ensnare&lt;/a&gt; (unfortunately not maintained anymore). &lt;/p&gt;

&lt;p&gt;I was wondering whether this form of attacker detection is actually practiced by you folks and what your experiences were in regards to successes, issues, implementation and maintenance effort.      &lt;/p&gt;

&lt;p&gt;Another, more recent illustration of this idea can be found in this talk by Dana Epp:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/5dukn9hcy_Q"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>security</category>
      <category>programming</category>
    </item>
    <item>
      <title>Cool ES6 Proxy Hacks</title>
      <dc:creator>Tolga Ünlü</dc:creator>
      <pubDate>Thu, 10 Jun 2021 11:23:57 +0000</pubDate>
      <link>https://forem.com/tolgadevsec/cool-es6-proxy-hacks-5dhm</link>
      <guid>https://forem.com/tolgadevsec/cool-es6-proxy-hacks-5dhm</guid>
      <description>&lt;p&gt;Coming across &lt;a href="https://github.com/justjavac/proxy-www"&gt;this&lt;/a&gt; creative approach of using fetch, I was wondering in what cool ways you folks take advantage of JavaScript ES6 Proxies?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Identifying Web Developer Awareness of Attack Attempts</title>
      <dc:creator>Tolga Ünlü</dc:creator>
      <pubDate>Mon, 23 Nov 2020 11:14:23 +0000</pubDate>
      <link>https://forem.com/tolgadevsec/identifying-web-developer-awareness-of-attack-attempts-4694</link>
      <guid>https://forem.com/tolgadevsec/identifying-web-developer-awareness-of-attack-attempts-4694</guid>
      <description>&lt;p&gt;Hello &lt;strong&gt;#DEVCommunity&lt;/strong&gt;!&lt;br&gt;
Get involved in making web applications self-defending and attack-aware. Our research aims to identify roadblocks in the integration of attack detection and response capabilities.&lt;/p&gt;

&lt;p&gt;Most attacker activities involve a probing phase in which an attacker attempts to discover exploitable vulnerabilities. As many of such attack attempts could be detected while validating an application's input, the goal of our survey is to identify whether developers understand attack indicators and how they can be best supported in building detectors for such indicators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Participation Requirements
&lt;/h2&gt;

&lt;p&gt;Are you of legal age (18+) and have experience in web development or have developed applications using web technologies? Then participate in our survey and support us with your professional insights.&lt;/p&gt;

&lt;h2&gt;
  
  
  Survey Details
&lt;/h2&gt;

&lt;p&gt;The survey is questionnaire-based and consists of three sections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the first section, you will be asked questions on your experience with security controls and input validation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second section consists of questions that will identify whether you can detect attack indicators.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the last section, you will be asked some general questions such that we can link you and your answers to a specific developer profile.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The survey can be accessed here: &lt;a href="https://forms.gle/NCH8hfbTggdVSmVe9"&gt;https://forms.gle/NCH8hfbTggdVSmVe9&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to get in touch with me should you have any questions or require further information. You can find my contact details on &lt;a href="https://tolgadevsec.github.io"&gt;my personal website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Your participation is appreciated and will support our goal of developing a pragmatic and usable attack-awareness integration solution. You are more than welcome to share this survey with your developer friends and colleagues.  &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>architecture</category>
      <category>devops</category>
    </item>
    <item>
      <title>Attack-Driven Defense for Web Applications</title>
      <dc:creator>Tolga Ünlü</dc:creator>
      <pubDate>Tue, 07 Jul 2020 11:01:33 +0000</pubDate>
      <link>https://forem.com/tolgadevsec/attack-driven-defense-for-web-applications-4do8</link>
      <guid>https://forem.com/tolgadevsec/attack-driven-defense-for-web-applications-4do8</guid>
      <description>&lt;p&gt;If you look at the common security controls that we are building into our web applications, you'll notice that they often do not have a feedback mechanism which tells the developers how the controls are performing against real threats in a production environment.&lt;/p&gt;

&lt;p&gt;This lack of feedback is a lost opportunity to gain a better understanding on real and imminent threats, which in turn could help developers to prioritize and improve their secure development efforts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Discovering generic attack indicators to build security controls that require less maintenance and can be used in different parts of the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Being able to see design flaws and rebuilding parts of an application which are secure by design. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building detection points that look for threat indicators and make the application respond defensively when a number of those detection points are triggered. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Utilizing this feedback to drive the security efforts of your development team is known as &lt;a href="https://www.oreilly.com/library/view/building-a-modern/9781492044680/ch01.html"&gt;attack-driven defense&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As this form of defense seems to be rather uncommon, I would like to hear your thoughts as developers on this, especially regarding the possibilities and shortcomings you see with this defense model.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are keen to learn more on how to utilize detection points to make your application attack-aware, have a look at this article where I give a brief introduction to this concept:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/tolgadevsec" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ce2i0OJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--GaYCuncj--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/415231/4856a9f9-a67d-4045-ba24-130c1f491cdb.png" alt="tolgadevsec"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/tolgadevsec/detecting-attackers-from-within-4095" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Detecting Attackers from Within&lt;/h2&gt;
      &lt;h3&gt;Tolga Ünlü ・ Jun 29 '20 ・ 6 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#security&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;

&lt;/blockquote&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>devops</category>
    </item>
    <item>
      <title>Detecting Attackers from Within</title>
      <dc:creator>Tolga Ünlü</dc:creator>
      <pubDate>Mon, 29 Jun 2020 11:27:33 +0000</pubDate>
      <link>https://forem.com/tolgadevsec/detecting-attackers-from-within-4095</link>
      <guid>https://forem.com/tolgadevsec/detecting-attackers-from-within-4095</guid>
      <description>&lt;p&gt;Modern secure development practices like &lt;em&gt;&lt;a href="https://cloud.google.com/solutions/devops/devops-tech-shifting-left-on-security"&gt;“shift left”&lt;/a&gt;&lt;/em&gt; security focus on resolving security issues early and within the development process. This includes the implementation of proactive controls, such as security logging and monitoring, which can give you insights into your application’s current security posture. In addition, knowing what goes on in your application from a security perspective can be further utilized to identify attacker activity by making your application attack-aware. &lt;/p&gt;

&lt;p&gt;Attack-aware applications, as described by the &lt;a href="https://owasp.org/www-pdf-archive/Owasp-appsensor-guide-v2.pdf"&gt;OWASP AppSensor&lt;/a&gt; project, rely on detection points, controls in your application code that check for blatant indicators of attacker activity. To see such detection points in action, the following parts of this article will go through some of them implemented within a small demo application. The demo application is built with the &lt;a href="https://expressjs.com/"&gt;Express&lt;/a&gt; web application framework and uses detection points built as validators from the &lt;a href="https://express-validator.github.io/docs/index.html"&gt;express-validator&lt;/a&gt; module. &lt;/p&gt;

&lt;p&gt;The application itself is very limited in functionality and provides only one endpoint (&lt;code&gt;/ticket&lt;/code&gt;) to submit user-controlled data. The submitted data is supposed to be a ticket, a JSON object consisting of three properties which will be validated by the detection points: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LSFzdpLC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nbjaviwxrcr7q9ojv6kk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LSFzdpLC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nbjaviwxrcr7q9ojv6kk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The demo application is available as a Glitch project (hit the &lt;strong&gt;Remix to Edit&lt;/strong&gt; button to work on your own instance of the application):&lt;/p&gt;


&lt;div class="glitch-embed-wrap"&gt;
  &lt;iframe src="https://glitch.com/embed/#!/embed/ticket-demo-application?previewFirst=true&amp;amp;attributionHidden=true&amp;amp;sidebarCollapsed=true&amp;amp;path=server.js" alt="ticket-demo-application on glitch"&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Note: Use the &lt;a href="https://glitch.com/edit/#!/ticket-demo-application"&gt;following link&lt;/a&gt; if the embedded glitch project is not loading&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Intrusion Detection with Detection Points
&lt;/h1&gt;

&lt;p&gt;As previously mentioned, the idea of detection points is to check for blatant indicators of attacker activity, activities that you would never expect from a benign user so to speak. In the demo application for example, a benign user can select only one of three possible ticket priority values from a dropdown menu. Being able to submit any other value is a sign of request tampering by using an interception proxy like &lt;a href="https://owasp.org/www-project-zap/"&gt;OWASP ZAP&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m_OKHzW2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cyz84kk4eakq1twv17t0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m_OKHzW2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cyz84kk4eakq1twv17t0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check for tampering activities with simple input validators such as those in the following code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;detectionPoints&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;priority&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;withMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Data Missing from Request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;bail&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isIn&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;low&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;medium&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;high&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;withMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Violation of Input Data Integrity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;

  &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;withMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Data Missing from Request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;

  &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;withMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Data Missing from Request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The validators check only for the parameters provided in the request body (&lt;code&gt;body("priority")&lt;/code&gt;, &lt;code&gt;body("title")&lt;/code&gt;, &lt;code&gt;body("description)&lt;/code&gt;) as these are the only ones of interest. For all three parameters, the first validator checks if the parameter &lt;code&gt;exists&lt;/code&gt; since it might has been removed or modified. You can then chain further validators as done with the &lt;code&gt;priority&lt;/code&gt; parameter where the next validator in the chain checks if the submitted priority value &lt;code&gt;isIn&lt;/code&gt; the array of acceptable values.  &lt;/p&gt;

&lt;p&gt;The detection points so far were implemented with the built-in validators, the express-validator module provides also a way to implement &lt;code&gt;custom&lt;/code&gt; validators. This can be handy if you want to make use of existing modules such as &lt;a href="https://www.npmjs.com/package/isomorphic-dompurify"&gt;Isomorphic DOMPurify&lt;/a&gt; for detection purposes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;detectionPoints&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;withMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Data Missing from Request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;custom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DOMPurify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sanitize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cross Site Scripting Attempt&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This custom validator does a lot more complex processing than the previous ones which is abstracted away from the developer behind a single method call. It is, however, this usable abstraction that makes it convenient to utilize DOMPurify for XSS detection, an attack class which is rather ineffective to detect with the use of simple input validation controls. &lt;/p&gt;

&lt;p&gt;This is an important aspect of implementing detection points as you will not want to spend too much time with &lt;em&gt;“detection engineering”&lt;/em&gt;. The focus should be on implementing simple but effective detection points, be it by adding new detection points to your application or by enhancing existing input validation controls.&lt;/p&gt;

&lt;h2&gt;
  
  
  Intrusion Response
&lt;/h2&gt;

&lt;p&gt;With the previously listed detection points in place, the demo application is now capable of detecting attacker activity. The logs generated by the triggered detection points can give the development team important insights into which part of the application is attacked and which attack techniques are deployed. To take this one step further, the triggered detection points can also be utilized to respond back defensively.     &lt;/p&gt;

&lt;p&gt;The decision whether and how to respond back can be based on a set of rules or thresholds that are exceeded. The demo application uses the latter approach to convey the idea of a defensive response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AttackMonitor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;threshold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; 
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;threshold&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;threshold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detections&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt; 
    &lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; 
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`[*] &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; @ [&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;] &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; - request.&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;param&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detections&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt; 
    &lt;span class="nx"&gt;isThresholdExceeded&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; 
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detections&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;threshold&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/ticket&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;attackMonitor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isThresholdExceeded&lt;/span&gt;&lt;span class="p"&gt;()){&lt;/span&gt; 
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`[*] Detection threshold exceeded - [&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;] &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is deactivated`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
  &lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ticket creation logic above is skipped when the number of triggered detection points exceeds a predefined threshold value. For real-world applications, however, you will want to consider more realistic responses such as: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requiring authentication for sensitive actions &lt;/li&gt;
&lt;li&gt;Deactivating accounts associated with attacker activity &lt;/li&gt;
&lt;li&gt;Reporting attacker activity to your development team on Slack &lt;/li&gt;
&lt;li&gt;Redirecting attackers to a honeypot hosting the same application but prepared with believable dummy data
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are just a few examples and your response capabilities are only limited by the technology with which your application is developed.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Accepting that the security measures in your application can and will be bypassed indicates a strong sense for security. It is therefore important that the security measures in place should not only focus on the preventive part but also provide the capabilities to detect and act on ongoing attacks in a timely fashion. &lt;/p&gt;

&lt;p&gt;Attack-aware applications make the best of preventive controls by utilizing them as detection points to establish an &lt;a href="https://www.oreilly.com/library/view/building-a-modern/9781492044680/ch01.html"&gt;attack-driven defense&lt;/a&gt; within the application. &lt;/p&gt;

&lt;h2&gt;
  
  
  Your Thoughts
&lt;/h2&gt;

&lt;p&gt;As intrusion detection and response within the application seems to be rather uncommon, it would be interesting to hear your thoughts on this concept. What do you think about this concept in general, what limitations and possibilities do you see from a developer's perspective?  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you want to stay up-to-date on the latest developments on this topic with research papers, articles and also developer studies in which you are welcome to participate in, then feel free to follow me here on &lt;a href="https://dev.to/tolgadevsec"&gt;DEV&lt;/a&gt; or &lt;a href="https://twitter.com/tolgauedev"&gt;Twitter&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Further Resources
&lt;/h2&gt;

&lt;p&gt;I have gathered here a few resources that you can look into if you want to learn more about attack-aware applications as well as attack-driven defense. &lt;/p&gt;

&lt;h3&gt;
  
  
  Reading Material
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://lcamtuf.blogspot.com/2010/06/intrusion-detection-doing-it-wrong.html"&gt;Intrusion detection: doing it wrong&lt;/a&gt;&lt;br&gt;
The detection points effectivity relies heavily on its secrecy among others. While security-by-obscurity is not the best strategy in certain contexts, it is, however, quite effective for detection purposes as explained by Michał Zalewski. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://owasp.org/www-pdf-archive/Owasp-appsensor-guide-v2.pdf"&gt;OWASP AppSensor Guide&lt;/a&gt; | &lt;a href="http://www.appsensor.org/"&gt;OWASP AppSensor&lt;/a&gt;&lt;br&gt;
Besides more than 50 detection points described in the OWASP AppSensor guide, the guide also includes 8 illustrative case studies on integrating attack awareness into different types of applications ranging from B2B web services to smart meters. The guide also covers advanced thresholds and responses in more detail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://owasp.org/www-project-proactive-controls/"&gt;OWASP Top 10 Proactive Controls 2018&lt;/a&gt;&lt;br&gt;
The proactive controls guide and especially the chapter on implementing security logging and monitoring provides more details and further references on the design and implementation of secure logging which was not covered in this article.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.darkreading.com/risk/for-real-security-dont-let-failure-be-your-measure-of-success/a/d-id/1335237"&gt;For Real Security, Don't Let Failure Be Your Measure of Success&lt;/a&gt;&lt;br&gt;
Zane Lackey writes in this article on the importance of not only focusing on how to keep the bad guys out (prevention) but also to think about what to do once they are in (detection and response).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Security Vulnerabilities Decomposition: Another Way To Look At Vulnerabilities&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this presentation, Katy Anton demonstrates how to decompose vulnerabilities into security controls (including detection points) that can be used by developers.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/5Ee_mWgRRQk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Whatever happened to attack aware applications?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Matthew Pendlebury talks in this presentation about attack-aware applications and why they still don't seem to be commonplace.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/HQxs3xn7tLA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lessons learned defending web applications in the age of DevOps/Cloud&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this keynote talk @ DevSecCon Singapore 2018, Zane Lackey shares his practical lessons learned at Etsy on how to defend modern web applications in a DevOps world. This talk will cover different topics, including obtaining security visibility.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ygs3PDfGn6Y"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;AppSensor: Real-Time Event Detection and Response&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This talk, given by John Melton, presents the OWASP AppSensor project and the model of self-protecting applications.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/OumAlyUHMcY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
