Skip to content

[Version: 3.11.0] Security events log proxy IP instead of client IP on Cloud Foundry #421

Description

@cschuerings

Description

The @cap-js/attachments plugin extracts the client IP address for security event audit logging using req.req?.socket?.remoteAddress (https://github.com/cap-js/attachments/blob/main/lib/generic-handlers.js). On BTP Cloud Foundry (and any reverse-proxy deployment), this returns the internal IP of the Go Router or Approuter — not the actual client IP.

This affects all three security events:

  • AttachmentSizeExceeded
  • AttachmentUploadRejected
  • AttachmentDownloadRejected

Current behavior

// lib/generic-handlers.js (3 occurrences)
const ipAddress = req.req?.socket?.remoteAddress

On CF, socket.remoteAddress resolves to the internal container/proxy IP (e.g., 10.x.x.x), making the logged IP useless for security forensics.

Expected behavior

The plugin should read X-Forwarded-For with fallback to socket.remoteAddress, consistent with how the Approuter extracts the client IP for audit logging:

// @sap/approuter — lib/utils/logger.js:76
let IP = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

Context

  • On BTP Cloud Foundry, the request chain is: ClientGo RouterApprouterBackend. The Go Router sets X-Forwarded-For with the real client IP.
  • @cap-js/audit-logging does not extract IP itself — it relies on the caller to provide the ip field, so the fix belongs in @cap-js/attachments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions