GenAIExamples icon indicating copy to clipboard operation
GenAIExamples copied to clipboard

[UI] UI container should NOT run with root privilege

Open Ruoyu-y opened this issue 1 year ago • 13 comments

Security guidelines would suggest running the containers without root privilege. However, both opea/chatqna-ui and opea/chatqna-conversation-ui requires root privilege to run. It brings potential risk to the system when the UI is running as a pod within Kubernetes such as privilege escalation, container escape, etc.

When running as non-root user of opea/chatqna-ui image,it fails with the following logs:

failed to load config from /home/user/svelte/vite.config.ts
error when starting preview server:
Error: EACCES: permission denied, open '/home/user/svelte/vite.config.ts.timestamp-1741934587046-d9551c9aabbc1.mjs'

When running as non-root user of opea/chatqna-conversation-ui, it fails with the following logs:

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/env.sh
APP_DATA_PREP_GET_FILE_URL=/v1/dataprep/get
sed: can't create temp file '/usr/share/nginx/html/assets/index-CMyKwVIa.cssXXXXXX': Permission denied
APP_DATA_PREP_SERVICE_URL=/v1/dataprep/ingest
sed: can't create temp file '/usr/share/nginx/html/assets/index-CMyKwVIa.cssXXXXXX': Permission denied
APP_BACKEND_SERVICE_ENDPOINT=/v1/chatqna
sed: can't create temp file '/usr/share/nginx/html/assets/index-CMyKwVIa.cssXXXXXX': Permission denied
APP_DATA_PREP_DELETE_FILE_URL=/v1/dataprep/delete
sed: can't create temp file '/usr/share/nginx/html/assets/index-CMyKwVIa.cssXXXXXX': Permission denied

This is not limited to chatqna-ui only, but is common for most of the svelte and react UI in GenAIExamples.

Ruoyu-y avatar Aug 02 '24 01:08 Ruoyu-y

Implementation of the Conversational UI requires root privilege to run

Why? Node / JS in general does not require that...

eero-t avatar Oct 25 '24 13:10 eero-t

@Ruoyu-y
Is this issue resolved?

xiguiw avatar Mar 03 '25 13:03 xiguiw

@jaswanth8888

It decreases the security of OPEA. This is a critical issue.

Pleased resolve is ASAP.

xiguiw avatar Mar 12 '25 01:03 xiguiw

I don't think this is specific to ChatQnA, I think it concerns all UIs containers?

@xiguiw please tag also related ticket in "GenAIInfra": https://github.com/opea-project/GenAIInfra/issues/500

eero-t avatar Mar 12 '25 13:03 eero-t

I've updated the bug description to be more precise. It's a common security bug for all svelte and react UIs. @xiguiw we need the maintainers to assign this to the correct owners.

lianhao avatar Mar 20 '25 01:03 lianhao

Ok, first issue seems to be wrong read access to config file, and second one is temp files being written to wrong location. If you make those 2 locations writable by non-root, are there additional issues?

eero-t avatar Mar 20 '25 11:03 eero-t

Hi @WenjiaoYue please help to consider the feature, thanks [Remind]

yinghu5 avatar Mar 27 '25 09:03 yinghu5

[Remind]:

@sgurunat Please help on this issue for React UI, thanks!

@WenjiaoYue Please help on this issue for svelte UI, Thanks!

xiguiw avatar Apr 07 '25 08:04 xiguiw

@xiguiw - Will look into this issue for React UI

sgurunat avatar Apr 07 '25 08:04 sgurunat

I don't think this is specific to ChatQnA, I think it concerns all UIs containers?

@xiguiw please tag also related ticket in "GenAIInfra": opea-project/GenAIInfra#500

@eero-t

  1. Yes. opea-project/GenAIInfra#500 UI pod is run with full privileges has dependency on this.
  2. It's not ChatQnA specific, the other examples UI have the same issue.

xiguiw avatar Apr 07 '25 08:04 xiguiw

[Remind] @WenjiaoYue Please look into this issue for svelte UI

xiguiw avatar Apr 16 '25 07:04 xiguiw

Just update for remind.

yinghu5 avatar Jun 11 '25 08:06 yinghu5

We have no resource for this issue for now, and v1.4 is approaching feature freeze. Let's solve it in v1.5.

joshuayao avatar Jun 30 '25 08:06 joshuayao