Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Don't allow HTTP origins for the CryptoToken extension.
Browse files Browse the repository at this point in the history
BUG=448214

Review URL: https://codereview.chromium.org/847193003

Cr-Commit-Position: refs/heads/master@{#311410}
  • Loading branch information
juanlang authored and Commit bot committed Jan 14, 2015
1 parent 936c15c commit 0ee19a5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chrome/browser/resources/cryptotoken/cryptotokenbackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
/** @const */
var BROWSER_SUPPORTS_TLS_CHANNEL_ID = true;

/** @const */
var HTTP_ORIGINS_ALLOWED = false;

/** @const */
var LOG_SAVER_EXTENSION_ID = 'fjajfjhkeibgmiggdfehjplbhmfkialk';

Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/resources/cryptotoken/enroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function handleWebEnrollRequest(messageSender, request, sendResponse) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}
if (sender.origin.indexOf('http://') == 0 && !HTTP_ORIGINS_ALLOWED) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}

if (!isValidEnrollRequest(request, 'enrollChallenges', 'signData')) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
Expand Down Expand Up @@ -124,6 +128,10 @@ function handleU2fEnrollRequest(messageSender, request, sendResponse) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}
if (sender.origin.indexOf('http://') == 0 && !HTTP_ORIGINS_ALLOWED) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}

if (!isValidEnrollRequest(request, 'registerRequests', 'signRequests',
'registeredKeys')) {
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/resources/cryptotoken/signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ function handleWebSignRequest(messageSender, request, sendResponse) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}
if (sender.origin.indexOf('http://') == 0 && !HTTP_ORIGINS_ALLOWED) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}

queuedSignRequest =
validateAndEnqueueSignRequest(
Expand Down Expand Up @@ -82,6 +86,10 @@ function handleU2fSignRequest(messageSender, request, sendResponse) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}
if (sender.origin.indexOf('http://') == 0 && !HTTP_ORIGINS_ALLOWED) {
sendErrorResponse({errorCode: ErrorCodes.BAD_REQUEST});
return null;
}

queuedSignRequest =
validateAndEnqueueSignRequest(
Expand Down

0 comments on commit 0ee19a5

Please sign in to comment.