mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix: serve JSON endpoints as application/json and build DOM safely
Several views returned json.dumps() output through HttpResponse, i.e. as text/html, and guess_mac_address reflects the URL's vname into it (reflected XSS). Templates filled the log table and volume dropdowns by concatenating server data into HTML strings, and log messages contain user-entered snapshot/disk/clone names (stored XSS that runs when a superuser opens the Logs tab). - Use JsonResponse in guess_mac_address, random_mac_address, guess_clone_name, sshkeys, storages.get_volumes, datasource.os_metadata_json and logs.vm_logs; sshkeys?plain=true is served as text/plain. - stats_tab.html builds log rows with .text(); instance.html and create_instance_w2.html build <option> elements with .val().text().
This commit is contained in:
parent
b1ab1d47fa
commit
4546653b5a
8 changed files with 140 additions and 29 deletions
|
|
@ -967,7 +967,7 @@
|
|||
$.getJSON(get_vol_url, function (data) {
|
||||
$("#image-control").find('option').remove();
|
||||
$.each(data['vols'], function(i, item) {
|
||||
$("#image-control").append('<option value=' + item +'>' + item + '</option>');
|
||||
$("#image-control").append($("<option>").val(item).text(item));
|
||||
});
|
||||
$('#image-control').multiselect('rebuild');
|
||||
});
|
||||
|
|
@ -978,7 +978,7 @@
|
|||
$.getJSON(get_vol_url, function (data) {
|
||||
$("#template").find('option').remove();
|
||||
$.each(data['vols'], function(i, item) {
|
||||
$("#template").append('<option value=' + item +'>' + item + '</option>');
|
||||
$("#template").append($("<option>").val(item).text(item));
|
||||
});
|
||||
});
|
||||
$("#template").removeAttr("disabled");
|
||||
|
|
@ -993,7 +993,7 @@
|
|||
$.getJSON(get_diskBus_url, function (data) {
|
||||
$("#bus" + dev_idx).find('option').remove();
|
||||
$.each(data['bus'], function(i, item) {
|
||||
$("#bus" + dev_idx).append('<option value=' + item +'>' + item + '</option>');
|
||||
$("#bus" + dev_idx).append($("<option>").val(item).text(item));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue