None
web100-2
BackdoorCTF - web - 100

In this problem, the challenge text just provided us a URL to the page, https://backdoor-web100.herokuapp.com/, which linked us to the source code on github.


<html>
    <head>
        <title>Underscore Template Tester</title>
        <style rel="stylesheet" type="text/cs" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.0/normalize.min.css"></style>
    </head>
    <body>
        <h1>Underscore Template Tester</h1>
        <form action="/templatize" method="POST">
            <p>This app takes in JSON data and a template and mashes them together using underscore.js</p>
            <textarea name="json" rows="10" cols="30" placeholder="Enter JSON data">{"package":"underscore_test","version": "2.9.12"}</textarea>
            <br>
            <textarea name="template" rows="10" cols="30" placeholder="Enter your template here">The name of the package is <%=package%> and its version is <%=version%></textarea>
            <br>
            <input type="submit" value="Convert!">
        </form><br>
        <p>Source code for this is available at https://github.com/backdoor-ctf/web100</p>
    </body>
</html>

Querying the server, it behaves pretty much as expected...

The name of the package is underscore_test and its version is 2.9.12

Going back to the source code reveals a very interesting line in app.js though:

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}
if(!process.env.FLAG)
{
  console.error("No flag in environment");
  process.exit(1);
}

So... the flag is stored in the environment on the server. Well, we have limited code execution - lets try to expose it!

16367694ede9faef0efec36845e18ceb

Flag: 16367694ede9faef0efec36845e18ceb


- Kelson (kelson@shysecurity.com)