<?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 Marcin Teodorczyk on Medium]]></title>
        <description><![CDATA[Stories by Marcin Teodorczyk on Medium]]></description>
        <link>https://medium.com/@marcin.teodorczyk?source=rss-7fb0c8dce2e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Marcin Teodorczyk on Medium</title>
            <link>https://medium.com/@marcin.teodorczyk?source=rss-7fb0c8dce2e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:10:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcin.teodorczyk/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[Hardening Docker Quick Tips]]></title>
            <link>https://medium.com/intive-developers/hardening-docker-quick-tips-54ca9c283964?source=rss-7fb0c8dce2e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/54ca9c283964</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[security-tips]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Marcin Teodorczyk]]></dc:creator>
            <pubDate>Wed, 29 May 2019 08:23:49 GMT</pubDate>
            <atom:updated>2019-05-29T08:25:54.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*mzLrEuFd0eoRl1DZv01SLQ.png" /></figure><p>It’s been over 6 years from the initial release of Docker on March 13, 2013. In the world of software development it looks more like a few centuries passed. Now, docker is widely regarded as mature and it is well working in many production environments. Also it has reasonably well functioning security controls enabled by default, namely namespaces, capabilities, cgroups. Nonetheless, due to the unavoidable differences in environments, it is not possible to make the best security configuration for everyone as a default.</p><p>If you want to take the security of your environment to the higher level, you can tweak controls that are already used by docker as well as add new ones. To make it easier to grasp one can split controls into two categories, namely related to docker host and related to docker images/containers.</p><h3>Host</h3><p>Briefly speaking, everything which comes with OS hardening topic should be considered here.</p><ol><li>We should have a minimal system, meaning no unnecessary software, services, users etc.</li><li>The system should be up to date, at least when it comes to security patches.</li><li>Services should be up to date. Particularly the docker daemon should be updated (some examples of serious vulnerabilities of docker from the last 2 years are <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-5736">CVE-2019–5736</a>, <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-11757">CVE-2018–11757</a>, <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-11756">CVE-2018–11756</a>, <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-9862">CVE-2018–9862</a>, <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-8115">CVE-2018–8115</a>).</li><li>Additionally we might choose to harden OS and basic services. For example enforce thoughtful policy on passwords, for SSH access maybe avoid passwords at all allowing users to only use cryptographic keys (disabling root login by the way) or limit docker daemon’s privileges and access to resources (more on that in the next part of the article).</li><li>Finally we can use some security extensions such as SELinux, Seccomp, AppArmor, GRSecurity or others. Most of those will require a lot of additional effort though.</li></ol><h3>Docker Daemon, Images and Containers</h3><p>In general, for docker images and containers the same principles as with host hardening apply. From the hardening perspective, the image can be viewed as an OS with one or more services (a proper image should include only one service and the software that is required by the service). The new thing here is the separation layer between the container and the docker host.</p><h4>Non-Root</h4><p>When building images it is worthwhile to create a low privilege user and then use it when running the container. We can do this adding following lines in Dockerfile:</p><blockquote>RUN adduser -D limited_user<br>USER limited_user</blockquote><p>The first one adds user named <em>limited_user</em>, the second one instructs docker to use this user inside the container. Apart from that we can specify the user when starting the container, like this:</p><blockquote><em>docker run -u limited_user ubuntu</em></blockquote><p>Of course the user specified in such way has to exist inside the container.</p><p>On a default centos host installation when running centos container with docker we get following output:</p><blockquote>[root@localhost ~]# docker run -it centos /bin/bash<br>[root@58428c062898 /]# id<br>uid=0(root) gid=0(root) groups=0(root)</blockquote><p>But when running with <em>-u </em>and user <em>nobody </em>(present inside the default centos image that is used), we see following:</p><blockquote>[root@localhost ~]# docker run -u nobody -it centos /bin/bash<br>bash-4.2$ id<br>uid=99(nobody) gid=99(nobody) groups=99(nobody)</blockquote><h4>Limit Resources</h4><p>Docker allows to limit resource availability per container. To allow the container to use no more than 1 CPU and 512MB of memory we use following:</p><blockquote>docker run -it — cpus 1 — memory 512Mb centos</blockquote><h4>Docker Content Trust</h4><p>When building images it is safer to use a trusted base OS and add needed software oneself than to get a ready to go image prepared by someone else, unless it is trustworthy. To ensure that we’re pulling the image that we think we’re pulling, we might use <a href="https://docs.docker.com/engine/security/trust/content_trust/">Docker Content Trust</a>.</p><h4>Check</h4><p>When we have above low hanging fruits covered we can go further. A great place to start is <a href="https://github.com/docker/docker-bench-security">docker-bench-security</a> — an open source project that checks for dozens of common best-practices around deploying Docker containers in production. When run on default centos 7 installation gives the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*HPnqyHUIP3jLKLtRqSj-8w.png" /><figcaption>docker-bench-security run on default centos7 installation</figcaption></figure><h4>Summary</h4><p>Docker is a great solution providing an additional layer of separation and increasing manageability in complex systems. Basic hardening of a default installation can be done within few minutes — don’t run as root and appropriately limit resources available to containers. If you want to address wider range of issues — try docker-bench-security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54ca9c283964" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intive-developers/hardening-docker-quick-tips-54ca9c283964">Hardening Docker Quick Tips</a> was originally published in <a href="https://medium.com/intive-developers">intive Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GravCMS: XSS via SVG]]></title>
            <link>https://medium.com/intive-developers/gravcms-xss-via-svg-af4b0b9ecaa5?source=rss-7fb0c8dce2e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/af4b0b9ecaa5</guid>
            <category><![CDATA[xs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Marcin Teodorczyk]]></dc:creator>
            <pubDate>Tue, 02 Apr 2019 07:56:49 GMT</pubDate>
            <atom:updated>2019-04-02T07:56:49.567Z</atom:updated>
            <content:encoded><![CDATA[<p>Previously I’ve described privilege <a href="https://medium.com/intive-developers/privilege-escalation-with-xss-in-grav-cms-e6ddc71714df">escalation with XSS</a> and <a href="https://medium.com/intive-developers/grav-cms-avatar-settings-as-a-door-to-superadmin-privileges-f7b30f3439bf">how to use user settings to gain admin privileges</a>. Now it’s time for the last article in the series on <a href="https://getgrav.org/">Grav CMS</a> — the least severe but quite interesting and often overlooked SVG file upload.</p><h3>Environment</h3><p>I’ve worked on Grav Devel and Admin Devel versions as of 21th of December, 2018, the default Grav installation, admin account and user account with following privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*gDjIZHU--HcuotUtyiu5VA.png" /></figure><h3>The Bug</h3><p>The Grav Team surely takes security of their platform seriously. Users can upload their own avatar file, but are restricted to precisely defined file types. Such whitelist approaches are most of the time the best from the perspective of security. However in this particular case, the allowed list of avatar file types includes SVG — quite complicated format, allowing embedded JavaScript.</p><p>A Malicious users can upload an SVG avatar. The avatar is then accessible with direct link in the domain of the CMS. If someone opens it in a browser, JavaScript will be executed in the context of the CMS domain and current user session if such exists.</p><h3>Proof of Concept</h3><p>Low privilege <em>user1</em> can upload SVG avatar including embedded JavaScript with two requests.</p><p>First, the user uploads a malicious file. As we can see in the request, the content of the file includes classic JavaScript PoC code: <em>alert(1)</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*kj6orRcSSHYYG6xKowTbrQ.png" /><figcaption>/admin/user/user1.json request (first)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*xY_32OotYP5hIfK4tU_Cuw.png" /><figcaption>/admin/user/user1.json response</figcaption></figure><p>Second, the user sets the previously uploaded file as his avatar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*We70YoT2YKPxlK3_ItDAnA.png" /><figcaption>/admin/user/user1 request (second)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*8Y9-R8zYEzXm6nBMK_gahw.png" /><figcaption>/admin/user/user1 response</figcaption></figure><p>Starting from now on, the file is available through the browser under the following endpoint <em>/user/accounts/avatars/1i0FpO3bmsq8ycD.svg,</em> which can be obtained from the above requests/replies.</p><p>If any user (or admin in particular) opens the endpoint in a browser, JavaScript will be executed as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*v5bAGvn5w8gTGKUi76vmSA.png" /></figure><p>If the victim is logged in, JavaScript might be able to perform some actions on behalf of the victim.</p><h3>Summary</h3><p>The presented bug is the least severe in the series of articles about Grav CMS. Many prerequisites are required to exploit it: a malicious user has to have an account and upload a malicious SVG avatar; then he has to somehow make a victim user open the direct link to the avatar — all while hoping that the victim will be logged in when opening the link.</p><p>Real world security is never black and white. Risks, costs and benefits always have to be taken into account. The presented scenario is quite low probable and poses rather low risk. In some cases it might be reasonably to give such bug low priority or even accept the risk. Nonetheless, surely it was fun to find it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af4b0b9ecaa5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intive-developers/gravcms-xss-via-svg-af4b0b9ecaa5">GravCMS: XSS via SVG</a> was originally published in <a href="https://medium.com/intive-developers">intive Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grav CMS: Avatar Settings as a Door to Superadmin Privileges]]></title>
            <link>https://medium.com/intive-developers/grav-cms-avatar-settings-as-a-door-to-superadmin-privileges-f7b30f3439bf?source=rss-7fb0c8dce2e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7b30f3439bf</guid>
            <category><![CDATA[grav]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <dc:creator><![CDATA[Marcin Teodorczyk]]></dc:creator>
            <pubDate>Tue, 05 Feb 2019 12:34:12 GMT</pubDate>
            <atom:updated>2019-02-05T12:34:12.291Z</atom:updated>
            <content:encoded><![CDATA[<p>A continuation of the <a href="https://medium.com/intive-developers/privilege-escalation-with-xss-in-grav-cms-e6ddc71714df">first article</a> related to <a href="https://getgrav.org/">Grav CMS</a>. This time a more serious privilege escalation related to avatar settings, also with more step by step details on how I’ve discovered it.</p><h3>Discovering the Bug</h3><p>I’ve started with the newest available release at the time, that is <em>Grav v1.6.0-beta.6 — Admin v1.9.0-beta.6</em>. During initial setup there is only a superadmin account created. Since I was going after privilege escalation bugs, I’ve also created a low privileged user named <em>user1</em>. After logging in as <em>user1</em> we can see following, basic dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4PADCQlbB-t_wNug6oklSA.png" /></figure><p>What instantly caught my attention after creating the user was that the following yaml file describing user’s settings has been created as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TmBGwh5ZYaoREFWrpMLZ-Q.png" /><figcaption>/var/www/html/grav/user/accounts/user1.yaml</figcaption></figure><p>One might first think that it’s nothing special, but after carefully reading the content, it becomes clear that there might be a potential for privilege escalation. Why? Because in the same file we have everything that is related to the user, from typical user attributes like email, name and title, to the most critical ones, like privileges (<em>access</em> section). Being quite sure the user can influence the content of this file, all I had to do was to find the request for that. After a brief browsing it came out to be a request of following form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*oaYSfAmbIa3O69yyyzLaoQ.png" /><figcaption>/admin/user/user1 request</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*iD-urxHkrb2MaLuEFbTGxA.png" /><figcaption>/admin/user/user1 response</figcaption></figure><p>The above request is sent when no avatar is set (notice <em>null</em> value for the <em>avatar </em>payload). Next I’ve tried to set an avatar. When doing this, the <em>null</em> payload of <em>Content-Disposition: form-data; name=”data[_json][avatar]”</em> section gets replaced by following (or similar) json:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZuXIQgHw-OsjwI7p5bsnFg.png" /></figure><p>This in turn maps to the content of the <em>avatar</em> section in the user settings yaml file as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9uZmRrtV_i_uUNat5CFQQ.png" /><figcaption>/var/www/html/grav/user/accounts/user1.yaml</figcaption></figure><p>Next, I’ve tried a few different payloads for <em>avatar</em> section of the request, observing how they’ve mapped in the user settings yaml file. Following that I’ve changed the <em>avatar</em> section name to something arbitrary. This resulted in a new section created in the user settings yaml file, also reflecting my request. This finally gave me an idea to try to just replace <em>avatar </em>section name with <em>access</em> section name and put payload for superadmin access rights. The only question was what the correct payload is? It was easy to answer as I could find it in the user settings yaml file of the superadmin (<em>admin.yaml</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-AHPqG-6o240jyun31k25Q.png" /></figure><p>Translated to json it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ccd5od5bQJjRNsdg6BE25Q.png" /></figure><h3>Exploiting</h3><p>Finally, it was time to put it all together — logged in as <em>user1</em> I’ve tried to grant me superadmin privileges sending as <em>user1</em> following request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mu6GHvUeUlp2ukpqyjDVYg.png" /><figcaption>/admin/user/user1 request</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zehXU-zS90m7PEdCjTitbg.png" /><figcaption>/admin/user/user1 response</figcaption></figure><p>The result has been following content of <em>user1.yaml</em> configuration file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mr6wjMLh1qlszyYkon_4Hg.png" /><figcaption>/var/www/html/grav/user/accounts/user1.yaml</figcaption></figure><p>Notice the highlighted <em>super: true </em>value. Indeed <em>user1</em> had superadmin privileges. After refreshing the session, <em>user1</em> has seen the following administrator dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEtQfdciwk5259IIOXZK9w.png" /></figure><h3>Summary</h3><p>I’ve disclosed the bug to the Grav Team on 13th of December 2018, as confirmed to be present in the <em>Grav 1.6.0-beta.6</em> version. The Grav Team response was again quick and professional describing that it has been already observed by them and fixing is in progress on DEV branch. The next release with a fix (Grav 1.6.0-beta.7) has been published the following day (14th of December 2018).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7b30f3439bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intive-developers/grav-cms-avatar-settings-as-a-door-to-superadmin-privileges-f7b30f3439bf">Grav CMS: Avatar Settings as a Door to Superadmin Privileges</a> was originally published in <a href="https://medium.com/intive-developers">intive Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege escalation with XSS in Grav CMS]]></title>
            <link>https://medium.com/intive-developers/privilege-escalation-with-xss-in-grav-cms-e6ddc71714df?source=rss-7fb0c8dce2e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6ddc71714df</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Marcin Teodorczyk]]></dc:creator>
            <pubDate>Wed, 07 Nov 2018 08:11:12 GMT</pubDate>
            <atom:updated>2018-11-07T08:11:12.942Z</atom:updated>
            <content:encoded><![CDATA[<p>Tracking down security bugs in web applications is an exciting task. It’s especially rewarding when a fast growing open source solution is on the workbench. An example of such is <a href="https://github.com/getgrav/grav">Grav CMS</a> — the most starred php-based CMS on github rapidly increasing its users base.</p><p>This article is a first of the three-part series that will describe a few security issues I’ve discovered and disclosed. Each article from the series will describe a different type of security issues. This one is about the well known XSS.</p><p>All the testing I did was performed on Grav 1.5.1 with at least one admin account and one user account created.</p><p>Let’s start from the end with an example of successful injection request. To make such a request one has to have a user account with page creation privilege enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*db0DvQdl3ilJNVe2ZDpdrg.png" /></figure><p>Following the server&#39;s response redirection we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_7z8lWU8VkWu7FKP-VMMQ.png" /></figure><p>One can notice, that there is an HTML with JavaScript code that will run. However, what’s most interesting, it won’t be the code within <em>&lt;script&gt;</em> tags which I couldn’t get a control of (it’s a leftover of HTML code from the page). Even though it’ll be treated as JavaScript it won’t do anything since it’s an HTML, and thus not valid JavaScript (one can see that it starts with <em>user1&lt;/option&gt;</em>)<em>. </em>To overcome such an obstruction I used <em>src</em> and <em>onerror</em> attributes of <em>script</em> tag and uploaded the malicious payload using the <em>onerror’</em>s value. This, of course, has some limitations, as one might not be able to use larger payload. However, in the tested Grav instance, a quick check proven, that it was possible to inject 10000 characters long payload.</p><p>OK, so we have at least reflected XSS. After taking a little bit more look at the application it came out that injected payload is stored in the database and used on a few subpages, examples being <em>home page </em>visited by all guests:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0O3nDQZpMzaFrconVd1mw.png" /></figure><p>and <em>page listing</em> in admin panel, typically used by admin or users with <em>create page</em> privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LncSEGwPqNPuWXL40HPnyA.png" /></figure><p>So finally, we have a stored XSS with the JavaScript that will be run in the contexts of all visitors as well as admins making an action on their behalf giving us classical privilege escalation.<br><br>The Grav Team response for the bug disclosure was fast and professional. After a short investigation it came up, that they’re aware of the few XSS issues and has been working on a generic solution. The next release with fix was promised to be delivered within two weeks. Indeed, Grav 1.5.2 with added &quot;XSS protection&quot; feature was released on the 1st of October, 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6ddc71714df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intive-developers/privilege-escalation-with-xss-in-grav-cms-e6ddc71714df">Privilege escalation with XSS in Grav CMS</a> was originally published in <a href="https://medium.com/intive-developers">intive Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>