origin page 3 - Dave's Blog

Search
My timeline on Mastodon

Stripe CTF - Level 7

2012 Sep 13, 5:00PermalinkCommentshash internet length-extension security sha1 stripe-ctf technical web

Stripe CTF - SQL injections (Levels 0 & 3)

2012 Sep 5, 9:10

Stripe's web security CTF's level 0 and level 3 had SQL injection solutions described below.

Level 0

Code

app.get('/*', function(req, res) {
var namespace = req.param('namespace');

if (namespace) {
var query = 'SELECT * FROM secrets WHERE key LIKE ? || ".%"';
db.all(query, namespace, function(err, secrets) {

Issue

There's no input validation on the namespace parameter and it is injected into the SQL query with no encoding applied. This means you can use the '%' character as the namespace which is the wildcard character matching all secrets.

Notes

Code review red flag was using strings to query the database. Additional levels made this harder to exploit by using an API with objects to construct a query rather than strings and by running a query that only returned a single row, only ran a single command, and didn't just dump out the results of the query to the caller.

Level 3

Code

@app.route('/login', methods=['POST'])
def login():
username = flask.request.form.get('username')
password = flask.request.form.get('password')

if not username:
return "Must provide username\n"

if not password:
return "Must provide password\n"

conn = sqlite3.connect(os.path.join(data_dir, 'users.db'))
cursor = conn.cursor()

query = """SELECT id, password_hash, salt FROM users
WHERE username = '{0}' LIMIT 1""".format(username)
cursor.execute(query)

res = cursor.fetchone()
if not res:
return "There's no such user {0}!\n".format(username)
user_id, password_hash, salt = res

calculated_hash = hashlib.sha256(password + salt)
if calculated_hash.hexdigest() != password_hash:
return "That's not the password for {0}!\n".format(username)

Issue

There's little input validation on username before it is used to constrcut a SQL query. There's no encoding applied when constructing the SQL query string which is used to, given a username, produce the hashed password and the associated salt. Accordingly one can make username a part of a SQL query command which ensures the original select returns nothing and provide a new SELECT via a UNION that returns some literal values for the hash and salt. For instance the following in blue is the query template and the red is the username injected SQL code:

SELECT id, password_hash, salt FROM users WHERE username = 'doesntexist' UNION SELECT id, ('5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8') AS password_hash, ('word') AS salt FROM users WHERE username = 'bob' LIMIT 1
In the above I've supplied my own salt and hash such that my salt (word) plus my password (pass) hashed produce the hash I provided above. Accordingly, by providing the above long and interesting looking username and password as 'pass' I can login as any user.

Notes

Code review red flag is again using strings to query the database. Although this level was made more difficult by using an API that returns only a single row and by using the execute method which only runs one command. I was forced to (as a SQL noob) learn the syntax of SELECT in order to figure out UNION and how to return my own literal values.

PermalinkCommentssecurity sql sql-injection technical web-security

Permanently Add Path to System PATH Environment Variable in PowerShell

2012 May 17, 7:16
According to MSDN the proper way to permanently add a path to your system's PATH environment variable is by modifying a registry value. Accordingly this is easily represented in a PowerShell script that first checks if the path provided is already there and otherwise appends it:
param([Parameter(Mandatory = $true)] [string] $Path);
$FullPathOriginal = (gp "HKLM:\System\CurrentControlSet\Control\Session Manager\Environment").Path;
if (!($FullPathOriginal.split(";") | ?{ $_ -like $Path })) {
sp "HKLM:\System\CurrentControlSet\Control\Session Manager\Environment" -name Path -value ($FullPathOriginal + ";" +
$Path);
}
PermalinkCommentspowershell registry technical code programming

"A More Granular Web Origin Concept" - Yoav Nir

2012 Mar 7, 8:01PermalinkCommentstechnical web origin

Client Side Cross Domain Data YQL Hack

2012 Feb 27, 2:28

One of the more limiting issues of writing client side script in the browser is the same origin limitations of XMLHttpRequest. The latest version of all browsers support a subset of CORS to allow servers to opt-in particular resources for cross-domain access. Since IE8 there's XDomainRequest and in all other browsers (including IE10) there's XHR L2's cross-origin request features. But the vast majority of resources out on the web do not opt-in using CORS headers and so client side only web apps like a podcast player or a feed reader aren't doable.

One hack-y way around this I've found is to use YQL as a CORS proxy. YQL applies the CORS header to all its responses and among its features it allows a caller to request an arbitrary XML, HTML, or JSON resource. So my network helper script first attempts to access a URI directly using XDomainRequest if that exists and XMLHttpRequest otherwise. If that fails it then tries to use XDR or XHR to access the URI via YQL. I wrap my URIs in the following manner, where type is either "html", "xml", or "json":

        yqlRequest = function(uri, method, type, onComplete, onError) {
var yqlUri = "http://query.yahooapis.com/v1/public/yql?q=" +
encodeURIComponent("SELECT * FROM " + type + ' where url="' + encodeURIComponent(uri) + '"');

if (type == "html") {
yqlUri += encodeURIComponent(" and xpath='/*'");
}
else if (type == "json") {
yqlUri += "&callback=&format=json";
}
...

This also means I can get JSON data itself without having to go through JSONP.
PermalinkCommentsxhr javascript yql client-side technical yahoo xdr cors

iPod Godfather Tony Fadell Finally Reveals His New Product: A Thermostat. No, Really. | TechCrunch

2011 Oct 25, 5:37
An original iPod guy has a new company that makes... wait for it... thermostats. Weird. Well they look cool anyway.
PermalinkCommentstechnical

draft-ietf-websec-origin-01 - The Web Origin Concept

2011 Jun 21, 1:22"This document defines the concept of an "origin", which is often used
as the scope of authority or privilege by user agents. Typically,
user agents isolate content retrieved from different origins to
prevent malicious web site operators from interfering with the
operation of benign web sites. In addition to outlining the
principles that underly the origin concept, this document defines how
to determine the origin of a URI, how to serialize an origin into a
string, and an HTTP header, named "Origin", that indicates which
origins are associated with an HTTP request."PermalinkCommentsietf reference technical web browser user-agent webbrowser origin

[whatwg] CORS requests for image and video elements

2011 May 23, 4:26Applying CORS to the media elements: "I've added a content attribute to <img>, <video>, and <audio> that makes the image or media resource be fetched with CORS And have the origin of the page if CORS succeeded. The attribute is "cross-origin" and it has two allowed values, "use-credentials" and "anonymous". The latter is the default, so you can just say <img cross-origin src="data.png">."PermalinkCommentscors crossdomain web browser webbrowser html technical

The ftp URI Scheme

2011 May 22, 10:38One step closer to completely deprecating the original URI spec by pulling out the ftp URI scheme specification into its own new updated spec!PermalinkCommentsuri url ftp uri-scheme ietf rfc reference technical

CSS Fonts Module Level 3

2011 May 10, 10:49Interesting standards disagreements showing up in specs: "Some implementers feel a same-origin restriction should be the default for all new resource types while others feel strongly that an opt-in strategy usuable for all resource types would be a better mechanism and that the default should always be to allow cross-origin linking for consistency with existing resource types (e.g. script, images). As such, this section should be considered at risk for removal if the consensus is to use an alternative mechanism."PermalinkCommentsreference web development font specification w3c css3

Never-before-seen footage of Eric Stoltz as Marty McFly in Back To The Future

2010 Oct 13, 3:11"To celebrate the 25th Anniversary of Back To The Future, we've got never-before-seen footage of original star Eric Stoltz as Marty McFly. Plus Robert Zemeckis, Steven Spielberg and Bob Gale all explaining why they replaced him with Michael J. Fox"PermalinkCommentsbacktothefuture bttf movie video eric-stoltz

Revision 60.000, first bits of the URL API and pingin’ the anchor « Peter Beverloo

2010 Sep 27, 3:08Adam Barth's URI API draft starts to appear in webkit: "One of the things Adam Barth is currently working on is an URL API. Citing it, the API can be used for constructing, parsing and resolving URLs through scripting, easening up tasks like getting and setting parameters. Today the first part landed in WebKit, which added the “origin” property."PermalinkCommentswebkit adam-barth uri url api javascript dom html html5 browser webbrowser technical

Shepard Fairey - Interview Magazine

2010 May 10, 8:59Iggy Pop interviews Shepard Fairey, including his Obama HOPE poster and AP lawsuit:

"... but the American public is generally pretty superficial, so an image like that just allows them to project whatever limited idea they have onto it. Obviously, not everyone is like that—I actually think there were a lot of people who were bummed by the image because they felt it was shallow propaganda."

"If I spend time conceiving and making a piece of art and somebody else sees that it has market value and replicates it in order to steal part of my market, then that’s not cool. But the way I make art—the way a lot of people make art—is as an extension of language and communication, where references are incredibly important. It’s about making a work that is inspired by something preexisting but changes it to have a new value and meaning that doesn’t in any way take away from the original—and, in fact, might provide the original with a second life or a new audience."
PermalinkCommentsart legal law ip shepard-fairey obey interview

5 Loading Web pages — HTML 5

2010 Apr 22, 10:26HTML5 has some notion of a 'null' origin. Not sure how this actually plays out though.PermalinkCommentsw3c site-of-origin null web browser application html html5 technical

Tao Effect Blog » Blog Archive » Steve Jobs’ response on Section 3.3.1

2010 Apr 11, 2:16Lots of links, info, and thoughts on Apple's change to the iPhone SDK terms of service that now state "Applications must be originally written in Objective-C, C, C++, or JavaScript..." Means no other languages or third party platforms...PermalinkCommentssteve-jobs apple sdk api tos legal law iphone ipod ipad technical

Client-side Cross-domain Security

2010 Mar 31, 7:54"Summary: Exploring cross-domain threats and use cases, security principles for cross-origin requests, and finally, weighing the risks for developers to enhance cross-domain access from web applications running in the browser."PermalinkCommentstechnical msdn microsoft security xss XMLHttpRequest web browser

YouTube - Galactica: Sabotage Comparison

2010 Mar 11, 11:50Side by side comparison of the BSG+Sabotage mashup and the original Sabotage music video. Cool remix certainly although it really must be watched in this side by side comparison form to be appreciated. By itself the remix isn't really coherent.
PermalinkCommentsbsg video humor music music-video sabotage beastie-boys

Part2 - browsersec - Browser Security Handbook, part 2 - Project Hosting on Google Code

2010 Mar 10, 5:19Covers same origin policy and how it applies to different HTML and HTTP features.PermalinkCommentstechnical web browser javascript csrf ajax html security xss XMLHttpRequest

Chromium Blog: Security in Depth: New Security Features

2010 Jan 27, 9:56Some of the new security features in Chrome: XSS filter, HTTPS only, HTML5 origin header, and HTML5 postMessage function.PermalinkCommentshtml5 html script xss csrf chrome browser google security web technical

Cheap Multiplayer Tricks for New Super Mario Bros. Wii

2010 Jan 5, 1:47

The New Super Mario Bros. Wii is a great game. Its the fun of old school Mario with the addition of great graphics and the kind of multiplayer I've wanted for Mario since playing the original as a child: its got up to four player simultaneous cooperative multiplayer. I recommend it to anyone who has enjoyed Mario in the past. Watch this amazing video of level 1-3 you can unlock in the game.

As noted elsewhere, multiple players attempting to navigate platforms, grab power ups, and throw turtle shells creates new challenges but along with that there's new ways to be incredibly cheap.

Jumping Higher
A second player means a head one can jump on to reach higher locations. Jump on your friend's head at the apex of their jump while holding down the jump button yourself for maximum jumping. In the game you can also grab other players and hold them over your head. This is useful for reaching the top of the flagpole at the end of levels. On that same line, if the player you grab has a flying cap you can now use them to fly in the same manner you would use a flying block which makes it easy to get two players to the top of the finish flagpole if only one of you has a flying cap.
Power-Ups
Normal power-up blocks now spawn enough power-ups for everyone. A mushroom is spawned for each small player and full power-ups for the rest, except in the case everyone is small: then one of the power-ups is a full power-up. If there's two players and you're both small, the full power-up always jumps out of the block to the right. Some hidden power-up blocks only give out one power-up and in that case its a mushroom or not based on the player who hits the block - so be sure that a big player hits that if you have one.
Death & Bubbles
When a player dies but at least one other player lives the dead player comes back in a limbo bubble from which they must be released before they may play again. Because of this, in a tough spot you can send one player in and leave a second behind. If the first dies you don't lose your place in the level and the first comes back in a bubble ready to try again. For instance, if you're trying to get the last star coin in 2-1 which sits just above the abyss, one player can just jump to their death for it and as long as another player lives you've collected the coin. However you need not sacrifice your life to do this: you can press down and 'a' to force yourself into a bubble saving yourself from death. This is true in general as long as you have enough time to see your death coming. This is also useful if one player runs ahead to the right. The screen will expand a bit but then it will just move to the right following the player in the lead. Players left behind walls or now forced into lava pits will die unless they use the bubble.
Misc.
  • If all players hit the ground at the same time from a ground pound it acts like hitting a pow block, killing the enemies on the screen.
  • If you hold a player who has a projectile power over your head they can still use their power.
  • Bubbles can be popped by hitting them with your fire or ice projectiles as well as thrown shells or blocks.
  • All players get the extra lives from anyone collecting 100 coins or finishing a level with more than 7 enemies on the screen.
PermalinkCommentsmultiplayer mario wii
Older EntriesNewer Entries Creative Commons License Some rights reserved.