Skip to content

Commit

Permalink
Fix potential severe XSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijah-Bodden authored Jul 29, 2022
1 parent 6f3473f commit f7b08c0
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions src/source/frontend/dist/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/** @format */

// Copyright 2022 Elijah Bodden

// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.


"use strict";

var CONFIG = {}
Expand Down Expand Up @@ -89,6 +82,16 @@ var defaultConfig = {
moderateMapInstabilityTolerance : true,
arbitraryPeerRouteTimeout : 100000000,
routeAcceptHeuristic : async function (pkg) {
if (pkg.desiredPermissions==="advanced") {
eventStream.log("system", `Peer authentication requested by ${CONFIG.UI.renderUnfamiliarPublicAliases ? (hiddenAliasLookup[pkg.sender] ?? pkg.sender) : pkg.sender}`, "transient", ["align-center", "system-message-card-route-pending", "message-card-slim"], pkg.sender)
var accepted = true
try {
await eventHandler.acquireExpectedDispatch(`authenticationAuthorized|${pkg.sender}`, CONFIG.communication.arbitraryPeerRouteTimeout)
} catch {
accepted = false
}
return accepted
}
return true
}
},
Expand All @@ -114,9 +117,30 @@ var defaultConfig = {
invalidSDP : 100,
},
configLoadFunction : async function() {
window.addEventListener("DOMContentLoaded", () => eventHandler.dispatch('DOMFunctional'), 1000)
window.addEventListener("DOMContentLoaded", () => eventHandler.dispatch("DOMFunctional"))
await eventHandler.acquireExpectedDispatch("DOMFunctional")
return {}
await fillDefaults()
effectiveFirstVisit = true
if (!JSON.parse(window.localStorage.config ?? "{}")?.["communication.publicAlias"] || !JSON.parse(window.localStorage.config ?? "{}").rememberMe) {
await (async () => {
var contentDisabler = document.createElement("iframe")
contentDisabler.style.position = "absolute"
contentDisabler.style.left = contentDisabler.style.right = contentDisabler.style.top = contentDisabler.style.bottom = "0px"
contentDisabler.style.width = contentDisabler.style.height = "100%"
contentDisabler.style.border = "0px"
contentDisabler.style.zIndex = 100000
document.querySelector("#init-blur-wrapper").style.visibility = "visible"
document.querySelector("#init-blur-wrapper").style.filter = "blur(3px) saturate(90%) brightness(90%)"
document.body.appendChild(contentDisabler)
const selectedHiddenAlias = await hiddenAliasPromptMenu()
document.querySelector("#init-blur-wrapper").replaceWith(...document.querySelector("#init-blur-wrapper").childNodes)
document.body.removeChild(contentDisabler)
exportToLS("communication.publicAlias", selectedHiddenAlias)
})()
} else {
document.querySelector("#init-blur-wrapper").replaceWith(...document.querySelector("#init-blur-wrapper").childNodes)
}
return JSON.parse(window.localStorage.config ?? "{}")
}
},
serverLink : {
Expand All @@ -129,6 +153,7 @@ var defaultConfig = {
}
}

var effectiveFirstVisit = false
const livePeers = {};
const authPeers = []
var serverHardRestart
Expand Down Expand Up @@ -284,10 +309,10 @@ class eventHandlingMechanism {
if (!hasResolved)
reject(
`Dispatch listener promise for the identifier ${dispatchIdentifier} timed out after ${
timeout ?? CONFIG.constants.defaultEventHandlingMechanismTimeout
timeout ?? CONFIG?.constants?.defaultEventHandlingMechanismTimeout ?? 100000
}ms`
);
}, timeout ?? CONFIG.constants.defaultEventHandlingMechanismTimeout);
}, timeout ?? CONFIG?.constants?.defaultEventHandlingMechanismTimeout ?? 100000)
}),
reject: rejectGeneratedPromise,
resolve: resolveGeneratedPromise,
Expand Down Expand Up @@ -759,7 +784,7 @@ class peerConnection {
switch (parsed[0]) {
case "consumable":
if (!this.peerData?.hiddenAlias) return
this.dispatchConsumableAuth(parsed[1].raw)
this.dispatchConsumableAuth(escapeHTML(parsed[1].raw))
break;
case "gossip":
gossipTransport.consumeGossip(parsed[1]);
Expand Down Expand Up @@ -1490,15 +1515,14 @@ async function onPublicError(callback) {
eventHandler.onReceipt("fatalError", callback)
}

//#to be defined as needed:
async function nonstandardParserDrain(type, args) {

//#to be individually defined
}

function indicateRouteAccepted(node) {

blinkStatus("success", node)
}

async function obviatePeerError(node) {

}
blinkStatus("error", node)
}

0 comments on commit f7b08c0

Please sign in to comment.