<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arshardh Ifthikar on Medium]]></title>
        <description><![CDATA[Stories by Arshardh Ifthikar on Medium]]></description>
        <link>https://medium.com/@arshardh?source=rss-14d16847d7b4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BVJj1UxhjhRScKoBn3T1bA.jpeg</url>
            <title>Stories by Arshardh Ifthikar on Medium</title>
            <link>https://medium.com/@arshardh?source=rss-14d16847d7b4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:12:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arshardh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Host Header Manipulation Vulnerability]]></title>
            <link>https://medium.com/thetechblogger/host-header-manipulation-vulnerability-7a5ddfe4c679?source=rss-14d16847d7b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a5ddfe4c679</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[thetechblogger]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[www]]></category>
            <dc:creator><![CDATA[Arshardh Ifthikar]]></dc:creator>
            <pubDate>Sat, 25 May 2019 20:20:54 GMT</pubDate>
            <atom:updated>2019-05-25T20:20:54.257Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*owv8SFCJCNc9YMx3wf2gFw.jpeg" /></figure><p>Security is a vital element when developing web applications. Most developers take security as a priority and work to make sure that their solution is secure. But there are certain vulnerabilities that are not that severe, but not paying attention to them can be lethal.</p><p>One such vulnerability is the host header manipulation vulnerability. There are many cases, in developing web applications where the developers trust the host header provided by the request for various activities. These include even important activities such as generating scripts, links which also include password reset links :o.</p><p>Although this host header is added to the request automatically (being the main reason for developers to trust this value), attackers can manipulate this value as they please. Therefore it is not advised to trust this value.</p><p>There are two main types of attacks that can be orchestrated using this vulnerability.</p><ol><li><strong>Password reset poisoning</strong></li><li><strong>Cache poisoning</strong></li></ol><h3><strong>Password reset poisoning</strong></h3><p>When a developer trusts this value, it can be used to generate a link to reset the password of a user. For instance, consider the following scenario:</p><p>When a user needs to reset a password, the developer generates the link to reset the password by populating the following template:</p><blockquote>$resetPasswordURL = “https://<em>{$_SERVER[‘HTTP_HOST’]}</em>/<strong>reset</strong>-<strong>password</strong>.php?token=12345678-1234-1234-1234-12345678901”</blockquote><p>And the token given here is a one time token so that the user will not need to enter the previous password once again. In this case, the attackers can easily rest the password of the said user.</p><p>More information on this can be found here: <a href="https://www.acunetix.com/blog/articles/password-reset-poisoning/">https://www.acunetix.com/blog/articles/password-reset-poisoning/</a></p><h3><strong>Web Cache Poisoning</strong></h3><p>Web cache poisoning is when an attacker manipulates the cache to serve poisoned malicious content to any party who requests pages. Such attacks are often difficult as all modern standalone caches are Host-aware.</p><p>More information on this can be found here: <a href="https://www.acunetix.com/blog/articles/what-is-web-cache-poisoning/">https://www.acunetix.com/blog/articles/what-is-web-cache-poisoning/</a></p><h3>Remedies</h3><p>It is always advised not to trust any header values sent by the client for critical operations. You can fetch the hostname by storing some kind of configuration. If you must use the host header as a mechanism for identifying the location of the web server, it’s highly advised to make use of a <strong>whitelist</strong> of allowed hostnames.</p><p>The best remedy is to create a dummy virtual host that catches all requests with unrecognized Host headers. Ideally, this redirection can be pointed at some error page. Steps to get this done is given below:</p><p><strong>Apache: </strong><a href="http://httpd.apache.org/docs/trunk/vhosts/examples.html#defaultallports">http://httpd.apache.org/docs/trunk/vhosts/examples.html#defaultallports</a></p><p><strong>Nginx: </strong><a href="https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/">https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/</a></p><h3>Further Reading</h3><ul><li><a href="https://www.acunetix.com/vulnerabilities/web/host-header-attack/">Host header attack - Vulnerabilities - Acunetix</a></li><li><a href="https://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html">Practical HTTP Host header attacks</a></li><li><a href="https://www.acunetix.com/blog/articles/automated-detection-of-host-header-attacks/">What is a Host Header Attack? | Acunetix</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a5ddfe4c679" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thetechblogger/host-header-manipulation-vulnerability-7a5ddfe4c679">Host Header Manipulation Vulnerability</a> was originally published in <a href="https://medium.com/thetechblogger">theTechBlogger</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Experience with Aspect Oriented Programming]]></title>
            <link>https://medium.com/thetechblogger/my-experience-with-aspect-oriented-programming-3613009c44ca?source=rss-14d16847d7b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3613009c44ca</guid>
            <category><![CDATA[aop]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[aspectj]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Arshardh Ifthikar]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 10:59:40 GMT</pubDate>
            <atom:updated>2019-02-17T10:59:40.962Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*o4SebT6vwnXtE-7atZFEDg.jpeg" /></figure><p>In the process of designing software, we encounter certain instances where we need to choose between different approaches to solve a problem. I face this issue all the time. Here I’ll share one such scenario, when I started to develop a solution to log the time taken to execute certain methods which are executed.</p><p>The conventional method to achieve this task would be to add logs to each and every important method. The negative aspect I saw in the conventional approach, was the addition of the unnecessary amount of lines to the code base. Another problem with the conventional approach was the inconvenience when adding new methods that needs to log the time, where we have to write the same time logging logic once again in the new method. And finally and obviously, the conventional approach will introduce a large amount of code duplication as well.</p><p>Therefore, I was determined to take a rather different approach. Once I realized this, I started looking for other approaches to take. That is when I came across the concept of Aspect Oriented Programming (AOP). Personally, I’m not a fan of quoting wikipedia, but this is the definition it gave me,</p><blockquote>In <a href="https://en.wikipedia.org/wiki/Computing">computing</a>, <strong>aspect-oriented programming</strong> (<strong>AOP</strong>) is a <a href="https://en.wikipedia.org/wiki/Programming_paradigm">programming paradigm</a> that aims to increase <a href="https://en.wikipedia.org/wiki/Modularity_(programming)">modularity</a> by allowing the <a href="https://en.wikipedia.org/wiki/Separation_of_concerns">separation of</a> <a href="https://en.wikipedia.org/wiki/Cross-cutting_concern">cross-cutting concerns</a>. It does so by adding additional behavior to existing code (an <a href="https://en.wikipedia.org/wiki/Advice_(programming)">advice</a>) <em>without</em> modifying the code itself, instead separately specifying which code is modified via a “<a href="https://en.wikipedia.org/wiki/Pointcut">pointcut</a>” specification, such as “log all function calls when the function’s name begins with ‘set’”. This allows behaviors that are not central to the <a href="https://en.wikipedia.org/wiki/Business_logic">business logic</a> (such as logging) to be added to a program without cluttering the code, core to the functionality. AOP forms a basis for <a href="https://en.wikipedia.org/wiki/Aspect-oriented_software_development">aspect-oriented software development</a>.</blockquote><blockquote>-Wikipedia :)</blockquote><p>Once I saw this definition, I thought to myself, “Yess!! This is what I wanted”. So, I dug deep to find out more about it. As the definition suggests, AOP allows the separation of cross cutting concerns which includes logging across the application as well.</p><p>Once I figured out this approach to be taken to solve the problem, I looked for a way to integrate this into the product I was working on, which was the <a href="https://wso2.com/api-management">WSO2 API Manager</a>. As some of you might know, the WSO2 Api Manager is a java based platform with maven and OSGI framework utilized to package it. Therefore, the next challenge I faced was to find a framework to achieve this.</p><p>This is where I came across AspectJ. AspectJ is an AOP extension written for java by PARC (<strong>Palo Alto Research Center</strong>) and can be found in Eclipse Foundation open source projects.</p><p>AspectJ takes instructions provided via aspects and generates the final implementation code. This process is called <strong><em>Aspect Weaving</em></strong>. AspectJ comprises of two types of weaving,</p><ol><li>Compile Time Weaving</li><li>Run Time Weaving</li></ol><p>Compile time weaving involves weaving at the compile time and Run time weaving involves just-in-time weaving by adding the weaver as a java agent. I utilized a performance test in order to decide between the two approaches, and compile time weaving had a high API gateway throughput than the runtime weaving option. Therefore I went ahead with compile time weaving.</p><h4>PointCuts</h4><p>AspectJ gives the ability to define certain pointcuts. These pointcuts give the programmer the ability to mention where to apply the given advices appropriately. It can also be seen as a filtering mechanism on applying the advices. There is a wide range of advices that can be given in defining pointcut expressions.</p><h4>Implementation of Solution</h4><p>First of all I added the functionality to log all methods of gateway handlers, without any logic to filtering out methods.</p><pre>@Pointcut(&quot;execution(* org.wso2.carbon.apimgt.gateway.handlers..*(..))&quot;)</pre><p>With this approach, I did a performance test to determine the overhead produced by utilizing aspectJ for my implementation. Then I noticed a pretty significant overhead (~20%), which was a significant overhead for our API Gateway.</p><p>Then I decided to limit the number of methods by adding a filtering logic. The following example shows a final pointcut expression I have utilized to achieve the method time logging for the API Gateway.</p><pre>@Pointcut(&quot;execution(* org.wso2.carbon.apimgt.gateway.handlers..*(..)) &quot; +<br>        &quot;&amp;&amp; (@annotation(MethodStats) || @target(MethodStats))&quot;)</pre><p>As you can notice, I have added the following part to the point cut expression:</p><pre>@annotation(MethodStats) || @target(MethodStats)</pre><p>Basically what I did was, adding an annotation named <strong><em>@MethodStats </em></strong>and marking every method and class that should be included in time logging with this annotation. The additional logic I applied to the pointcut ensures this. This helped me to log method execution times only for the important methods which helped me to reduce the overhead to a minute amount (~0.4%).</p><p>In the future if someone implements new methods or classes that needs to be included in time logging, all they have to do is to mark the respective method or class with the annotation, <strong><em>@MethodStats</em></strong>.</p><h4>Conclusion</h4><p>Aspect Oriented Programming is an awesome mechanism to consider when implementing a solution if you utilize it properly. What you can achieve using AOP totally depends on your creativity. But be mindful about the performance overhead introduced by it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3613009c44ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thetechblogger/my-experience-with-aspect-oriented-programming-3613009c44ca">My Experience with Aspect Oriented Programming</a> was originally published in <a href="https://medium.com/thetechblogger">theTechBlogger</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Utilizing Improved Observability of WSO2 API Manager]]></title>
            <link>https://medium.com/api-integration-essentials/utilizing-improved-observability-of-wso2-api-manager-5ed58367f44a?source=rss-14d16847d7b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ed58367f44a</guid>
            <category><![CDATA[api-management]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[wso2-apim]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[Arshardh Ifthikar]]></dc:creator>
            <pubDate>Thu, 22 Nov 2018 18:05:53 GMT</pubDate>
            <atom:updated>2020-02-14T05:43:32.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*c_1dRmfeV5s8ERo1aaLZLA.jpeg" /></figure><p>Observability is an important aspect of a system. The observability of a software system is really important to debug issues in a short period of time. To address this concern, the <a href="https://wso2.com/api-management/">WSO2 API Manager</a> have implemented a solution to log different important points of the system, with the time taken to achieve them. This solution will consist of three types points that will be logged.</p><ol><li>Method Calls</li><li>External Calls (HTTP/HTTPS)</li><li>Database Calls (JDBC and LDAP)</li></ol><p>In our effort to provide observability, we have given the users the facility to correlate these three types of calls with the help of a correlationID.</p><p>A random correlation id is generated within the api manager for each transaction. A unique correlation id can be provided by adding the header, “<strong><em>activityid</em></strong>” to the request sent to the API Manager.</p><p>Observability features can be activated by simply adding a system property named <strong><em>enableCorrelationLogs</em></strong> with the value <strong><em>true</em></strong>. This system property can be added to the wso2server script file as shown below,</p><blockquote>-DenableCorrelationLogs=true</blockquote><p>The log file can be found in the following path:</p><blockquote>&lt;CARBON_HOME&gt;/repository/logs/correlation.log.</blockquote><h4>1. Method Calls</h4><p>Once correlation logging is enabled, the api manager logs the time taken to execute certain important methods of the modules, gateway, keymgt and impl. These important methods are marked with an annotation, @MethodStats. This annotation can be found in both method level and class level. If this annotation is given to a class, all the methods of the respective class are included for logging. If all methods of a package are required to be logged, the package name needs to be given as the value of the system property, <strong><em>logAllMethods</em></strong>. The format of the method logging is given below,</p><blockquote>timestamp | correlationID | threadName | duration | callType | className | methodName | methodArguments</blockquote><h4>2. External Calls</h4><p>The observability feature offers two types of external call logging.</p><p><strong>Synapse global handler level</strong></p><p>All external calls done by the API Manager is logged via this category. Note that this does not include DB calls. This is done via a synapse global handler that logs the important information of the external calls. The format for the synapse global handler level external call logging can be found below,</p><blockquote>timestamp | correlationID | threadName | duration(BE latency) | callType | apiName | apiMethod | apiContext | apiResourcePath | authHeader | orgIdHeader | SrcIdHeader | applIdHeader | uuIdHeader | requestSize | responseSize | apiResponseStatusCode | applicationName | consumerKey | responseTime</blockquote><p><strong>Synapse passthrough transport level</strong></p><p>In contrast to the information provided by the synapse global handler level, the passthrough transport level gives certain additional data such as, the synapse internal state of the request. The format for the synapse passthrough transport level external call logging can be found below,</p><blockquote><em>timestamp|correlationID|threadName|duration|callType|connectionName|methodType|connectionURL|httpState</em></blockquote><h4>3. Database Calls</h4><p>The database call logging for observability includes two types of DB calls, namely LDAP calls and JDBC calls. This will help to track down any latencies caused by a database calls in an instance.</p><p>The format for database call logging is given below,</p><h4>JDBC</h4><blockquote>timestamp | correlationID | threadID | duration | callType | startTime | methodName | query | connectionUrl</blockquote><h4>LDAP</h4><blockquote>timestamp | correlationID | threadID | duration | callType | startTime | methodName | providerUrl | principal | argsLengeth | args</blockquote><h3>Utilizing these logs to gather information</h3><p>Now that we have gone through the theory :), let’s focus on how to utilize these logs in a practical scenario.</p><h4>Scenario: A request sent to the API Manager takes a lot of time to respond back</h4><p>This can happen due to several reasons,</p><ul><li>Due to an programming error</li><li>Due to a backend service call taking time</li><li>Due to a database call taking time</li></ul><p>Follow the following steps to pinpoint the bottleneck,</p><ol><li>You can list the times consumed by the code level, using the following command. This will help you to pinpoint method level latencies.</li></ol><blockquote>cat correlation.log | grep “|METHOD|” | cut -d “|” -f4 | sort -n</blockquote><p>This will give the time consumed by each method in ascending order. Then if there is no noticeably significant time consumption by some method, take the five methods with the largest time consumption, and pick the method with the unusually high time consumption.</p><p>2. If a clear method with a high time consumption <strong>cannot</strong> be identified, take the 5 most time consuming service and database calls, with the same correlation ID of the method logs, and find out the unusually time consuming call.</p><blockquote>cat correlation.log | grep “correlationID” | grep “|HTTP|” | cut -d “|” -f4 | sort -n</blockquote><blockquote>cat correlation.log | grep “correlationID” | grep “|DB_CALL|” | cut -d “|” -f4 | sort -n</blockquote><p>Observability features are now available for WSO2 API Manager 2.1.0, 2.5.0 and 2.6.0, via the latest wum updates, and also in our git repository (<a href="https://github.com/wso2/product-apim/tree/2.x">https://github.com/wso2/product-apim/tree/2.x</a>). <strong><em>When obtaining these features with wum updates, please make sure to follow the instructions available in the update summary</em></strong>.</p><p>A demonstration video of the observability features is available via the following link, <a href="https://youtu.be/qWlXHNRyHBE">https://youtu.be/qWlXHNRyHBE</a></p><p>I really hope that this article would have helped you to setup observability for the WSO2 API Manager.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ed58367f44a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/api-integration-essentials/utilizing-improved-observability-of-wso2-api-manager-5ed58367f44a">Utilizing Improved Observability of WSO2 API Manager</a> was originally published in <a href="https://medium.com/api-integration-essentials">API Integration Essentials</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>