Skip to content

Commit 8ccc429

Browse files
committed
Security Fix issue jplayer#162 for CVE-2013-2023
1 parent c1c7a4d commit 8ccc429

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

actionscript/Jplayer.as

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* - http://www.gnu.org/copyleft/gpl.html
99
*
1010
* Author: Mark J Panaghiston
11-
* Version: 2.3.0
12-
* Date: 20th April 2013
11+
* Version: 2.3.1
12+
* Date: 14th May 2013
1313
*
1414
* FlashVars expected: (AS3 property of: loaderInfo.parameters)
1515
* id: (URL Encoded: String) Id of jPlayer instance
@@ -69,15 +69,14 @@ package {
6969
private var isMp3:Boolean = false;
7070
private var isVideo:Boolean = false;
7171

72-
private var securityIssue:Boolean = false; // When SWF parameters contain illegal characters
73-
private var directAccess:Boolean = false; // When SWF visited directly with no parameters (or when security issue detected)
72+
private var securityIssue:Boolean = false; // On direct access and when SWF parameters contain illegal characters
7473

7574
private var txLog:TextField;
7675
private var debug:Boolean = false; // Set debug to false for release compile!
7776
private var localAIRDebug:Boolean = false; // This is autodetermined by AIR app - leave false!
7877

7978
private var traceOut:TraceOut;
80-
//private var outgoing_lc = new LocalConnection ();
79+
8180
public function Jplayer() {
8281

8382
flash.system.Security.allowDomain("*");
@@ -90,6 +89,7 @@ package {
9089
stage.align = StageAlign.TOP_LEFT;
9190

9291
if(!securityIssue) {
92+
// The jQuery param is the primary cause of security concerns.
9393
jQuery = loaderInfo.parameters.jQuery + "('#" + loaderInfo.parameters.id + "').jPlayer";
9494
commonStatus.volume = Number(loaderInfo.parameters.vol);
9595
commonStatus.muted = loaderInfo.parameters.muted == "true";
@@ -128,7 +128,7 @@ package {
128128
contextMenu = myContextMenu;
129129

130130
// Log console for dev compile option: debug
131-
if(debug || directAccess) {
131+
if(debug || securityIssue) {
132132
txLog = new TextField();
133133
txLog.x = 5;
134134
txLog.y = 5;
@@ -137,17 +137,13 @@ package {
137137
txLog.backgroundColor = 0xEEEEFF;
138138
txLog.border = true;
139139
txLog.background = true;
140+
txLog.multiline = true;
140141
txLog.text = "jPlayer " + JplayerStatus.VERSION;
141142

142-
if(debug) {
143-
txLog.multiline = true;
144-
txLog.visible = false;
145-
} else if(directAccess) {
143+
if(securityIssue) {
146144
txLog.visible = true;
147-
}
148-
if(debug && directAccess) {
149-
txLog.visible = true;
150-
log("Direct Access");
145+
} else if(debug) {
146+
txLog.visible = false;
151147
}
152148

153149
this.addChild(txLog);
@@ -227,23 +223,29 @@ package {
227223
}
228224
}
229225
private function checkFlashVars(p:Object):void {
230-
var i:Number = 0;
231-
for each (var s:String in p) {
232-
if(illegalChar(s)) {
233-
securityIssue = true; // Illegal char found
226+
// Check for direct access. Inspired by mediaelement.js - Also added name to object for non-IE browsers.
227+
if(ExternalInterface.objectID != null && ExternalInterface.objectID.toString() != "") {
228+
for each (var s:String in p) {
229+
if(illegalChar(s) || illegalWord(s)) {
230+
securityIssue = true; // Found a security concern.
231+
}
234232
}
235-
i++;
236-
}
237-
if(i === 0 || securityIssue) {
238-
directAccess = true;
233+
} else {
234+
securityIssue = true; // Direct access disables the callbacks, which were a security concern.
239235
}
240236
}
241237
private function illegalChar(s:String):Boolean {
242-
var illegals:String = "' \" ( ) { } * + / \\ < > = document alert";
238+
// A whitelist of accepted chars.
239+
var validParam:RegExp = /^[-A-Za-z0-9_.]+$/;
240+
return !validParam.test(s);
241+
}
242+
private function illegalWord(s:String):Boolean {
243+
// A blacklist of JavaScript commands that are a security concern.
244+
var illegals:String = "eval document alert confirm prompt console";
243245
if(Boolean(s)) { // Otherwise exception if parameter null.
244246
for each (var illegal:String in illegals.split(' ')) {
245247
if(s.indexOf(illegal) >= 0) {
246-
return true; // Illegal char found
248+
return true; // Illegal word found
247249
}
248250
}
249251
}
@@ -552,7 +554,7 @@ package {
552554
resizeEntity(videoItem, mediaX, mediaY, mediaWidth, mediaHeight);
553555
}
554556
}
555-
if((debug || directAccess) && stage.stageWidth > 20 && stage.stageHeight > 20) {
557+
if((debug || securityIssue) && stage.stageWidth > 20 && stage.stageHeight > 20) {
556558
txLog.width = stage.stageWidth - 10;
557559
txLog.height = stage.stageHeight - 10;
558560
}

actionscript/happyworm/jPlayer/JplayerStatus.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package happyworm.jPlayer {
1515
public class JplayerStatus {
1616

17-
public static const VERSION:String = "2.3.0"; // The version of the Flash jPlayer entity.
17+
public static const VERSION:String = "2.3.1"; // The version of the Flash jPlayer entity.
1818

1919
public var volume:Number = 0.5; // Not affected by reset()
2020
public var muted:Boolean = false; // Not affected by reset()

jquery.jplayer/Jplayer.swf

51 Bytes
Binary file not shown.

jquery.jplayer/jquery.jplayer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* - http://www.gnu.org/copyleft/gpl.html
99
*
1010
* Author: Mark J Panaghiston
11-
* Version: 2.3.0
12-
* Date: 20th April 2013
11+
* Version: 2.3.1
12+
* Date: 14th May 2013
1313
*/
1414

1515
/* Code verified using http://www.jshint.com/ */
@@ -454,8 +454,8 @@
454454
$.jPlayer.prototype = {
455455
count: 0, // Static Variable: Change it via prototype.
456456
version: { // Static Object
457-
script: "2.3.0",
458-
needFlash: "2.3.0",
457+
script: "2.3.1",
458+
needFlash: "2.3.1",
459459
flash: "unknown"
460460
},
461461
options: { // Instanced in $.jPlayer() constructor
@@ -1003,6 +1003,7 @@
10031003

10041004
htmlObj = document.createElement("object");
10051005
htmlObj.setAttribute("id", this.internal.flash.id);
1006+
htmlObj.setAttribute("name", this.internal.flash.id);
10061007
htmlObj.setAttribute("data", this.internal.flash.swf);
10071008
htmlObj.setAttribute("type", "application/x-shockwave-flash");
10081009
htmlObj.setAttribute("width", "1"); // Non-zero

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jplayer",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "The jQuery HTML5 Audio / Video Library",
55
"homepage": "http://www.jplayer.org/",
66
"keywords": [

0 commit comments

Comments
 (0)