BCApps icon indicating copy to clipboard operation
BCApps copied to clipboard

[Vendor] [Quality Management] Agentic review - Security: Missing Permission Checks in Manufacturing Integration

Open PredragMaricic opened this issue 9 months ago • 2 comments

Describe the issue

SEC-005: Missing Permission Checks in Manufacturing Integration

Severity: Medium
File: src/Integration/Manufacturing/QltyManufacturIntegration.Codeunit.al
Lines: 240-247

Issue:
The manufacturing integration codeunit checks WritePermission() before processing but logs the permission denial instead of throwing an error. This silent failure could lead to data integrity issues where users expect quality tests to be updated but the operation silently fails.

Current Code:

local procedure UpdateReferencesForProductionOrderLine(...)
var
    QltyInspectionTestHeader: Record "Qlty. Inspection Test Header";
    TargetRecordRef: RecordRef;
begin
    TargetRecordRef.GetTable(NewProdOrderLine);
    if not QltyInspectionTestHeader.WritePermission() then begin
        LogProductionProblemWith1(TargetRecordRef, PermissionErr, UserId());
        exit;  // Silent failure - no error thrown!
    end;

    // Continue with update logic...
end;

Security Concerns:

  1. Silent Authorization Failure: User isn't notified their action failed due to permissions
  2. Data Inconsistency Risk: Production order updates proceed while quality tests aren't updated
  3. Audit Log Only: Failure logged but not surfaced to user or system error handling
  4. User Confusion: Users may believe operation succeeded when it partially failed

Business Impact:

  • Production orders change status
  • Associated quality tests remain pointing to old production order
  • Quality inspection results become orphaned or misaligned
  • Inventory could be released without proper quality clearance

Recommended Fix:

local procedure UpdateReferencesForProductionOrderLine(...)
var
    QltyInspectionTestHeader: Record "Qlty. Inspection Test Header";
    TargetRecordRef: RecordRef;
    PermissionErrorMsg: Label 'You do not have permission to update quality inspection tests. Production order changes may not be reflected in quality tests. Contact your administrator.';
begin
    TargetRecordRef.GetTable(NewProdOrderLine);
   
    // FIX 1: Throw error instead of silent exit
    if not QltyInspectionTestHeader.WritePermission() then begin
        LogProductionProblemWith1(TargetRecordRef, PermissionErr, UserId());
        Error(PermissionErrorMsg);  // Fail the entire operation
    end;

    // ALTERNATIVE FIX 2: Use notification for non-blocking alert
    if not QltyInspectionTestHeader.WritePermission() then begin
        LogProductionProblemWith1(TargetRecordRef, PermissionErr, UserId());
        ShowPermissionWarningNotification(PermissionErrorMsg);
        exit;
    end;

    // Continue with update logic...
end;

local procedure ShowPermissionWarningNotification(MessageText: Text)
var
    PermissionNotification: Notification;
begin
    PermissionNotification.Message := MessageText;
    PermissionNotification.Scope := NotificationScope::LocalScope;
    PermissionNotification.Send();
end;

Same Issue Found In:

  • UpdateReferencesForProductionOrder (lines 218-225)
  • UpdateReferencesForProductionOrderRoutingLine (lines 292-299)
  • src/Integration/Receiving/QltyReceivingIntegration.Codeunit.al (multiple locations)

Recommended Approach:

  1. Critical Operations: Throw errors to block the entire transaction
  2. Background Processes: Use notifications or warnings
  3. Always Log: Maintain audit trail regardless of approach
  4. UI Feedback: Ensure users understand what succeeded and what failed

Estimated Risk: Medium - could lead to operational and compliance issues.

Expected behavior

Steps to reproduce

Additional context

I will provide a fix for a bug

  • [x] I will provide a fix for a bug

PredragMaricic avatar Feb 03 '26 10:02 PredragMaricic

The behavior you’re seeing is intentional. Updating a reference on the inspection header is informational only and is not considered a critical operation. As such, a user without Quality Management permissions must still be able to complete a production order.

The stated business impact, inventory not being released without proper quality clearance, is not accurate in this context. Inventory blocking and release are governed by item and item tracking configuration (including lot block status and dispositions), not by the this reference.

Given that, a more appropriate approach would be to disable the feature that attempts to update the reference altogether. This is already configurable via the Production Update Control setting in the Quality Inspector setup.

I’d recommend that change instead. Let me know if that addresses the concern.

insightworks007 avatar Feb 03 '26 19:02 insightworks007

Thanks @insightworks007, Sorry, I've already worked on this to clean-up telemetry logging, so closing as a "duplicate" of https://github.com/microsoft/BCApps/pull/6506

JakovljevicDusan avatar Feb 09 '26 19:02 JakovljevicDusan