Repository navigation
Conversation
…onsistent translation function
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
JSON-RPC and HTTP API methods had not enough or inconsistent profile check leading to potential vulnerability
Changes
JSON-RPC API (
core/api/jeeApi.php)admin,user,restrict).$_USER_GLOBALis set).plugin != core): out of scope, each plugin keeps handling its own API.adminby default, so a method added later is protected even if someone forgets to add it to the table.hasRight()checks on eqLogic, cmd and scenario are kept.core/ajax/*.ajax.php):config::byKey,config::save: nowadminonly (previously any profile).log::get,log::getDelta,log::getLastLine,log::list: nowadminonly (previouslyadmin,user). Theapilog records full requests, including API keys, so auserprofile could read another user's or the core API key.scenario::save,scenario::import: nowadminonly.scenario::hasRight()always returnstruefor theuserprofile, so anyusercould save a scenario with a PHP code block, i.e. execute code aswww-data.cmd::save: nowadminonly. Previously ausercould change any existing command (pre/post actions, linked equipment, …).update::all: nowadminonly (previouslyadmin,user,restrict).HTTP API (
type=...)type=message: nowadminonly, likemessage::add.type=variable: reading requiresadminoruser(likedatastore::byTypeLinkIdKey), writing requiresadmin(likedatastore::save).type=scenariowithout id,type=eqLogic,type=command: results are now filtered withhasRight(), like their JSON-RPC equivalents.Shell injection hardening
jeedom::forceSyncHour():ntp::optionalServermust be a valid hostname or IP address (filter_var). Otherwise the default NTP server is used. The value is then passed throughescapeshellarg().report::clean():report::maxdaysis checked withFILTER_VALIDATE_INT(min_range0) and inserted with%d. An invalid or empty value now skips the cleanup, which matches the previous behaviour, wherefindfailed on such values.Breaking changes
userprofile can no longer use these API methods:log::*(read),cmd::save,scenario::save,scenario::import,update::all.restrictprofile can no longer useupdate::all.type=message) or write variables (type=variable).restrictusers can no longer read variables.restrictusers now only get the scenarios, equipments and commands they have rights on.-32701. Some methods used-32001before (jeedom::halt/reboot/update/backup,eqLogic::save,cmd::save).Impact on json-rpc API
log::get,log::getDelta,log::getLastLine,log::listapilog records each full request, including itsapikey(log::add('api', 'info', secureXSS($request) ...)). Ausercan therefore read an admin API key or the core key and escalate to admin. The entire web interface for logs (log.ajax.php) is already restricted to admin.scenario::save,scenario::importhasRight('w')→ adminscenario::hasRight()always returnstruefor auser(scenario.class.php:1509-1511). Anyusercan therefore save a scenario containing a PHP code block, meaning arbitrary code execution aswww-data. In the web interface,savealready requires admin.cmd::savehasRight(admin only at creation) → adminusercan modify any existing command: pre‑ and post‑execution actions, linking it to another device, etc. This allows triggering actions outside their permissions. In the web interface,savealready requires admin.update::allupdate.ajax.phprequires admin. It is also inconsistent thatrestrictcan access it whileusercannot accessupdate::nbNeedUpdate.Impact on HTTP API
variable(write)datastore::save(admin).variable(read)datastore::byTypeLinkIdKey.messagemessage::add.scenariowithout id,object,eqLogic,commandhasRightrestrictuser sees everything, whereas the equivalent JSON‑RPC methods already apply filtering.Testing
php -lon the modified files.admin,userandrestrictprofiles on the methods listed above;getJson,event::changes,jeeObject::full,cmd::execCmd);Suggested changelog entry
Types of changes