trust - Dave's Blog

Search
My timeline on Mastodon

Changing the User Agent string in UWP WebView

2018 Oct 23, 9:32

There's no perfect way to change the user agent string for the UWP WebView (x-ms-webview in HTML, Windows.UI.Xaml.Controls.WebView in XAML, and Windows.Web.UI.Interop.WebViewControl in Win32) but there are two imperfect methods folks end up using.

The first is to call UrlMkSetSessionOption. This is an old public API that allows you to configure various arcane options including one that is the default user agent string for requests running through urlmon. This API is allowed by the Microsoft Store for UWP apps. The change it applies is process wide which has two potential drawbacks. If you want to be able to have different UA strings set for different requests from a WebView that's not really possible with this solution. The other drawback is if you're using out of process WebView, you need to ensure you're calling into UrlMkSetSessionOption in the WebView's process. You'll need to write third party WinRT that calls UrlMkSetSessionOption, create the out of proc WebView, navigate it to some trusted local page, use AddWebAllowedObject or provide that URI WinRT access, and call into your third party WinRT. You'll need to do that for any new WebView process you create.

The second less generally applicable solution is to use NavigateWithHttpRequestMessage and set the User-Agent HTTP header. In this case you get to control the scope of the user agent string changes but has the limitations that not all sub resource downloads will use this user agent string and for navigations you don't initiate you have to manually intercept and re-request being careful to transfer over all POST body state and HTTP headers correctly. That last part is not actually possible for iframes.

PermalinkCommentsuser-agent uwp webview

Tweet from David Risney

2016 Dec 7, 2:19
I'm going to pretend that The Circle is a sequel to Antitrust http://kottke.org/16/12/trailer-for-the-circle 
PermalinkComments

Retweet of kennwhite

2016 Feb 2, 4:34
I didn't realize so many Debian/Ubuntu apps don't/can't do cert verification. Also "untrusted websites" is a thing. pic.twitter.com/euTZzXuxzw
PermalinkComments

Retweet of olemoudi

2015 Sep 18, 4:21
Shell-XSS: Never trust cat again http://openwall.com/lists/oss-security/2015/09/17/5 …
PermalinkComments

Tweet from David_Risney

2015 Apr 6, 9:21
How to decide to trust a password mgr? Have to write my own to be sure of author's intentions. But then also sure mgr will have dumb flaws.
PermalinkComments

Untrusted - a user javascript adventure game

2014 Apr 8, 6:53

The game is to figure out what constrained modifications you must make to beat the game.

PermalinkCommentstechnical programming javascript game

URI functions in Windows Store Applications

2013 Jul 25, 1:00PermalinkCommentsc# c++ javascript technical uri windows windows-runtime windows-store

Windows Store on Windows 8 Fun For Independent Developers

2013 Jun 24, 1:00
Having worked on Windows 8 I'm not in a neutral position to review aspects of it, however I'll say from a high level I love taking the following various positives from smart phone apps and app stores and applying it to the desktop:
  • Independent developers can easily publish apps.
  • One trusted place for a user to find apps.
  • User can trust apps are limited to a declared set of capabilities.
  • One common and easy way for users to buy and try apps.
  • Easy mechanism for independent developers to collect revenue.
Relieving the independent developer of software development overhead, in this case Windows taking care of distribution and sales infrastructure is wonderful for me with my third party developer hat on. This combined with my new found fun of developing in JavaScript and the new Windows Runtime APIs means I've been implementing and finishing various ideas I've had - some for fun and some for productivity on my Surface. Development notes to follow.
PermalinkCommentsstore technical windows windows-store

Stripe CTF - XSS, CSRF (Levels 4 & 6)

2012 Sep 10, 4:43

Level 4 and level 6 of the Stripe CTF had solutions around XSS.

Level 4

Code

> Registered Users 

    <%@registered_users.each do |user| %>
    <%last_active = user[:last_active].strftime('%H:%M:%S UTC') %>
    <%if @trusts_me.include?(user[:username]) %>

  • <%= user[:username] %>
    (password: <%= user[:password] %>, last active <%= last_active %>)
  • Issue

    The level 4 web application lets you transfer karma to another user and in doing so you are also forced to expose your password to that user. The main user page displays a list of users who have transfered karma to you along with their password. The password is not HTML encoded so we can inject HTML into that user's browser. For instance, we could create an account with the following HTML as the password which will result in XSS with that HTML:

    
    
    This HTML runs script that uses jQuery to post to the transfer URI resulting in a transfer of karma from the attacked user to the attacker user, and also the attacked user's password.

    Notes

    Code review red flags in this case included lack of encoding when using user controlled content to create HTML content, storing passwords in plain text in the database, and displaying passwords generally. By design the web app shows users passwords which is a very bad idea.

    Level 6

    Code

    
    

    ...

    def self.safe_insert(table, key_values)
    key_values.each do |key, value|
    # Just in case people try to exfiltrate
    # level07-password-holder's password
    if value.kind_of?(String) &&
    (value.include?('"') || value.include?("'"))
    raise "Value has unsafe characters"
    end
    end

    conn[table].insert(key_values)
    end

    Issue

    This web app does a much better job than the level 4 app with HTML injection. They use encoding whenever creating HTML using user controlled data, however they don't use encoding when injecting JSON data into script (see post_data initialization above). This JSON data is the last five most recent messages sent on the app so we get to inject script directly. However, the system also ensures that no strings we write contains single or double quotes so we can't get out of the string in the JSON data directly. As it turns out, HTML lets you jump out of a script block using no matter where you are in script. For instance, in the middle of a value in some JSON data we can jump out of script. But we still want to run script, so we can jump right back in. So the frame so far for the message we're going to post is the following:

    
    
    
    
PermalinkCommentscsrf encoding html internet javascript percent-encoding script security stripe-ctf technical web xss

Capturing HTTPS with FiddlerCore

2011 Apr 6, 10:00

I used FiddlerCore in GeolocMock to edit HTTPS responses and ran into two stumbling blocks that I'll document here. The first is that I didn't check if the Fiddler root cert existed or was installed, which of course is necessary to edit HTTPS traffic. The following is my code where I check for the certs.

    if (!Fiddler.CertMaker.rootCertExists())
{
if (!Fiddler.CertMaker.createRootCert())
{
throw new Exception("Unable to create cert for FiddlerCore.");
}
}

if (!Fiddler.CertMaker.rootCertIsTrusted())
{
if (!Fiddler.CertMaker.trustRootCert())
{
throw new Exception("Unable to install FiddlerCore's cert.");
}
}

The second problem I had (which would have been solved had I read all the sample code first) was that my changes weren't being applied. In my app I only need the BeforeResponse but in order to modify the response I must also sign up for the BeforeRequest event and mark the bBufferResponse flag on the session before the response comes back. For example:

    Fiddler.FiddlerApplication.BeforeRequest += new SessionStateHandler(FiddlerApplication_BeforeRequest);
Fiddler.FiddlerApplication.BeforeResponse += new SessionStateHandler(FiddlerApplication_BeforeResponse);
...
private void FiddlerApplication_BeforeRequest(Session oSession)
{
if (IsInterestingSession(oSession))
{
oSession.bBufferResponse = true;
}
}
PermalinkCommentshttp fiddler technical https geolocmock programming fiddlercore

WebSandbox - Microsoft Live Labs

2010 May 6, 7:16"Today web gadgets, mashup components, advertisements, and other 3rd party content on websites either run with full trust alongside your content or are isolated inside of IFrames. As a result, many modern web applications are intrinsically insecure, often with unpredictable service quality. Live Labs Web Sandbox addresses this problem."PermalinkCommentsweb browser web-sandbox technical javascript html windows live security sandbox microsoft silverlight

How to Setup Your Own Web Proxy Server For Free with Google App Engine [Video Tutorial]

2010 Mar 4, 3:05Intro to Google App Engine plus get a somewhat more trustworthy web proxy than you'd normally find on the Internet...PermalinkCommentsapi proxy web google free technical

Why the internet will fail (from 1995) « Three Word Chant!

2010 Feb 26, 8:50Did I read this already on Paleo-Future? Anyway still an awesome 1995 rant on why the Internet will fail. "Then there’s cyberbusiness. We’re promised instant catalog shopping–just point and click for great deals. We’ll order airline tickets over the network, make restaurant reservations and negotiate sales contracts. Stores will become obselete. So how come my local mall does more business in an afternoon than the entire Internet handles in a month? Even if there were a trustworthy way to send money over the Internet–which there isn’t–the network is missing a most essential ingredient of capitalism: salespeople."PermalinkCommentshumor internet fail article history

Joho the Blog » Broadband. Trust them.

2009 Sep 25, 5:18"The closest the organization comes to stating its actual intent is in the wording of the print ad they’re running. Hmm. On the open medium of the Internet the organization hides its purpose, but in the controlled medium of print, they come close to stating it. How unexpected!"PermalinkCommentsnet-neutrality network-neutrality network internet broadband isp cable humor

EU objects to browser in Windows | Microsoft - CNET News

2009 Jan 16, 4:02"European regulators notified Microsoft it believes the software giant is in violation of the region's antitrust laws by bundling its Internet Explorer browser in Windows, the company said Friday."PermalinkCommentsmicrosoft news browser opera browser-war ie windows eu

McCain Booed For Telling Audience To Be Respectful of Obama - From The Road

2008 Oct 13, 11:52"Some of the questioners said they were scared of an Obama presidency, and one woman said she couldn't trust Obama because "he's an Arab." McCain shook his head. "No ma'am, he's a decent family man, a citizen, that I just happen to have disagreements with on fundamental issues, and that's what this campaign is all about."PermalinkCommentspolitics obama mccain article

Paleo-Future: The Internet? Bah! (1995)

2008 Apr 1, 11:21'95 article on the Internet fad: "So how come my local mall does more business in an afternoon than the entire Internet handles in a month? Even if there were a trustworthy way to send money over the Internet--which there isn't--the network is missing a mPermalinkCommentshumor article internet news history future

WebSlices now appearing in a Wikipedia article near you - istartedsomething

2008 Mar 28, 10:07"Trust the open-source lovin' contributors at Wikipedia to be early adopters of Microsoft web technologies. Beginning just a couple of days ago, Wikipedia user "Soum Yasch" began building Wiki templates to support the new content-subscription featurPermalinkCommentsie8 ie browser wikipedia article

FOAF and OpenID: two great tastes that taste great together | Decentralized Information Group (DIG) Breadcrumbs

2007 Nov 28, 4:43How to use FOAF and OpenID together and how DIG used that as a basis for commenting on their blog.PermalinkCommentsfoaf openid authentication identity rdf semanticweb trust web spam

PGP Signing FOAF Files

2007 Oct 10, 9:21Howto on signing your FoaF documents.PermalinkCommentspgp security signing web trust foaf rdf semanticweb xml encryption howto
Older Entries Creative Commons License Some rights reserved.