You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Krishnauprit18 (via GitHub)" <gi...@apache.org> on 2026/09/03 05:14:19 UTC
[PR] Improved: Route the layout-image events through the permission-checked content services and tighten data resource template rendering [ofbiz-framework]
Krishnauprit18 opened a new pull request, #1846:
URL: https://github.com/apache/ofbiz-framework/pull/1846
- Aligns updateLayoutImage and cloneLayout with the rest of the content component: their DataResource / Content writes now go through the permission-checked services (updateDataResource, updateContent) instead of storing the entities directly, and updateLayoutImage can no longer change a resource's type.
- Also removes the unused updateLayoutImageOnly mapping, requires CONTENTMGR_SUPER on createDataTemplateType / updateDataTemplateType / deleteDataTemplateType, and restricts DataResourceWorker template rendering — no *_OBJECT source, FTL allow-list instead of deny-list, SCREEN_COMBINED only from a component:// location.
- Adds UpdateLayoutPermissionTests for the low-privilege (OFBTOOLS_VIEW / CONTENTMGR_VIEW) case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improved: Route the layout-image events through the permission-checked content services and tighten data resource template rendering [ofbiz-framework]
Posted by "golja (via GitHub) via notifications" <no...@ofbiz.apache.org>.
golja commented on PR #1846:
URL: https://github.com/apache/ofbiz-framework/pull/1846#issuecomment-6637640741
CVE-2026-85627
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improved: Route the layout-image events through the permission-checked content services and tighten data resource template rendering [ofbiz-framework]
Posted by "ashishvijaywargiya (via GitHub)" <gi...@apache.org>.
ashishvijaywargiya merged PR #1846:
URL: https://github.com/apache/ofbiz-framework/pull/1846
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improved: Route the layout-image events through the permission-checked content services and tighten data resource template rendering [ofbiz-framework]
Posted by "golja (via GitHub) via notifications" <no...@ofbiz.apache.org>.
golja commented on PR #1846:
URL: https://github.com/apache/ofbiz-framework/pull/1846#issuecomment-6637686556
CVE-2026-84183
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Improved: Route the layout-image events through the permission-checked content services and tighten data resource template rendering [ofbiz-framework]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1846:
URL: https://github.com/apache/ofbiz-framework/pull/1846#discussion_r3921319343
##########
applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java:
##########
@@ -338,6 +374,21 @@ public static String cloneLayout(HttpServletRequest request, HttpServletResponse
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
+ // cloning writes new Content, DataResource and ContentAssoc rows directly, so check the
+ // content-manager permission here: CONTENTMGR create, and CONTENTMGR_SUPER as well when
+ // the source data resource is template-bearing (the clone would be template-bearing too),
+ // matching what the createContent / updateDataResource services require.
+ Security security = (Security) request.getAttribute("security");
+ GenericValue srcDataResource = EntityQuery.use(delegator).from("DataResource")
+ .where("dataResourceId", content.getString("dataResourceId")).queryOne();
+ String srcTemplateType = srcDataResource != null ? srcDataResource.getString("dataTemplateTypeId") : null;
+ boolean srcIsTemplate = UtilValidate.isNotEmpty(srcTemplateType) && !"NONE".equals(srcTemplateType);
+ if (security == null || !security.hasEntityPermission("CONTENTMGR", "_CREATE", userLogin)
+ || (srcIsTemplate && !security.hasEntityPermission("CONTENTMGR_SUPER", "_CREATE", userLogin))) {
+ request.setAttribute("_ERROR_MESSAGE_",
+ UtilProperties.getMessage("ContentUiLabels", "ContentPermissionNotGranted", locale));
+ return "error";
+ }
Review Comment:
PR description says cloneLayout now routes Content/DataResource writes through permission-checked services, but cloneLayout still creates Content/DataResource/ContentAssoc entities directly (lines 392+). The added hasEntityPermission check is not equivalent to the service-layer permission-service checks and bypasses any service overrides/validation (e.g., allow-html rules, ECA triggers).
##########
applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java:
##########
@@ -204,19 +205,54 @@ public static String updateLayoutImage(HttpServletRequest request, HttpServletRe
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
if (Debug.verboseOn()) {
- Debug.logVerbose("in createLayoutImage(java), dataResource:" + dataResource, "");
+ Debug.logVerbose("in createLayoutImage(java), dataResource:" + dataResource + ", imageFileName:" + imageFileName, "");
}
- // Use objectInfo field to store the name of the file, since there is no
- // place in ImageDataResource for it.
- if (Debug.verboseOn()) {
- Debug.logVerbose("in createLayoutImage(java), imageFileName:" + imageFileName, "");
+ if (dataResource == null) {
+ request.setAttribute("_ERROR_MESSAGE_",
+ UtilProperties.getMessage(ERR_RESOURCE, "layoutEvents.data_ressource_id_null", locale));
+ return "error";
}
- if (dataResource != null) {
- dataResource.setNonPKFields(context);
- dataResource.store();
+ // This event maintains the image bytes and image metadata of an existing IMAGE_OBJECT
+ // layout resource. It does not edit the DataResource entity directly: the editable
+ // metadata fields go through the updateDataResource service, so permission is checked the
+ // same way as every other data resource update (genericDataResourcePermission, main-action
+ // UPDATE, which requires CONTENTMGR_SUPER for a template-bearing data resource). A data
+ // resource that is already template-bearing is left to that dedicated path, and
+ // dataResourceTypeId / dataTemplateTypeId are pinned so this event cannot reclassify a
+ // resource - the aligned behaviour to updateLayout (see OFBIZ #1745).
+ String existingTemplateType = dataResource.getString("dataTemplateTypeId");
+ if (UtilValidate.isNotEmpty(existingTemplateType) && !"NONE".equals(existingTemplateType)) {
+ request.setAttribute("_ERROR_MESSAGE_",
+ UtilProperties.getMessage("ContentUiLabels", "ContentPermissionNotGranted", locale));
+ return "error";
+ }
+ LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+ GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
+ Map<String, Object> updateDrCtx = new HashMap<>();
+ updateDrCtx.put("dataResourceId", dataResourceId);
+ updateDrCtx.put("userLogin", userLogin);
+ for (String editableField : UtilMisc.toList("dataResourceName", "statusId", "mimeTypeId",
+ "localeString", "isPublic", "objectInfo")) {
+ Object value = context.get(editableField);
+ if (value != null) {
+ updateDrCtx.put(editableField, value);
+ }
+ }
+ // pin the classification: this event only ever maintains a plain IMAGE_OBJECT resource
+ updateDrCtx.put("dataResourceTypeId", "IMAGE_OBJECT");
+ updateDrCtx.put("dataTemplateTypeId", "NONE");
+ try {
Review Comment:
updateLayoutImage claims to “pin the classification” so the event cannot reclassify a resource, but it unconditionally passes dataResourceTypeId=IMAGE_OBJECT to updateDataResource. If an attacker supplies a different dataResourceId, this would actively change that DataResource’s type to IMAGE_OBJECT instead of rejecting it.
##########
applications/content/src/test/groovy/org/apache/ofbiz/content/permission/UpdateLayoutPermissionTests.groovy:
##########
@@ -72,6 +72,42 @@ class UpdateLayoutPermissionTests implements JupiterTestHelper {
}
}
+ /**
+ * updateLayoutImage and cloneLayout now route every DataResource / ImageDataResource / Content
+ * write through the same permission-checked services the rest of the content component uses,
+ * instead of storing the entities directly. These assertions exercise those delegated calls for
+ * the view-only profile: each must be denied, and converting a data resource into a
Review Comment:
This new test’s Javadoc claims updateLayoutImage/cloneLayout route “every DataResource / ImageDataResource / Content write” through permission-checked services, but the current code still writes ImageDataResource (updateLayoutImage) and Content/DataResource/ContentAssoc (cloneLayout) directly. The comment is misleading unless the events are fully refactored to delegate all writes.
##########
applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java:
##########
@@ -204,19 +205,54 @@ public static String updateLayoutImage(HttpServletRequest request, HttpServletRe
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
if (Debug.verboseOn()) {
- Debug.logVerbose("in createLayoutImage(java), dataResource:" + dataResource, "");
+ Debug.logVerbose("in createLayoutImage(java), dataResource:" + dataResource + ", imageFileName:" + imageFileName, "");
}
Review Comment:
The verbose log message inside updateLayoutImage still says "in createLayoutImage(java)" which makes it harder to trace issues when debugging layout image updates (other log lines in this method use the same prefix).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org