Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ac0d528

Browse files
committed
fix($sanitize): blacklist the attribute usemap as it can be used as a security exploit
Backport of 234053f. Closes #14903 BREAKING CHANGE: The `$sanitize` service will now remove instances of the `usemap` attribute from any elements passed to it. This attribute is used to reference another element by `name` or `id`. Since the `name` and `id` attributes are already blacklisted, a sanitized `usemap` attribute could only reference unsanitized content, which is a security risk.
1 parent 8d83b56 commit ac0d528

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/ngSanitize/sanitize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ var validElements = angular.extend({},
204204
optionalEndTagElements);
205205

206206
//Attributes that have href and hence need to be sanitized
207-
var uriAttrs = makeMap("background,cite,href,longdesc,src,usemap");
207+
var uriAttrs = makeMap("background,cite,href,longdesc,src");
208208
var validAttrs = angular.extend({}, uriAttrs, makeMap(
209209
'abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,'+
210210
'color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,'+

test/ngSanitize/sanitizeSpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ describe('HTML', function() {
174174

175175
it('should remove unsafe value', function() {
176176
expectHTML('<a href="javascript:alert()">').toEqual('<a></a>');
177+
expectHTML('<img src="foo.gif" usemap="#foomap">').toEqual('<img src="foo.gif"/>');
177178
});
178179

179180
it('should handle self closed elements', function() {

0 commit comments

Comments
 (0)