Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSC failed to run signed Docker image #162

Open
NandiniKJ opened this issue Jul 17, 2023 · 93 comments
Open

GSC failed to run signed Docker image #162

NandiniKJ opened this issue Jul 17, 2023 · 93 comments

Comments

@NandiniKJ
Copy link

Description of the problem

We are trying to run a Docker image using Gramine shielded containers.
We are successfully able to create the signed image but the container is throwing the below error when we try to run the signed docker image.

Screenshot 2023-07-17 at 12 04 20 PM

We have been following this link: https://gramine.readthedocs.io/projects/gsc/en/latest/

We were able to bring this application up with normal container deployment and were able to verify that the start-baffle-shiled.sh file exists. After converting to and running inside Gramine container I found that the opt folder is empty.

Could you help us with this, are we missing something here.

Steps to reproduce

Expected results

Actual results

@mkow
Copy link
Member

mkow commented Jul 17, 2023

Please don't paste screenshots of text, instead just copy and paste the text itself. It's hard to read and makes it impossible to copy and search in it.

@dimakuv
Copy link
Contributor

dimakuv commented Jul 17, 2023

After converting to and running inside Gramine container I found that the opt folder is empty.

This doesn't sound right. GSC doesn't do anything with the /opt directory. So I don't know why it becomes empty.

@NandiniKJ
Copy link
Author

NandiniKJ commented Jul 17, 2023

I am able to run the docker image without Gramine and it works fine. Please find the below output. After converting it to Gramine container should we mount the /opt path or change the entrypoint.sh. I'm I missing something here.

`SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/baffle/Release-Baffle.1.7.0.161/shield/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/baffle/Release-Baffle.1.7.0.161/shield/bm-connector.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
2023-07-17 10:49:08,086 1 INFO CommonConfig:508 - baffle.config.bmShieldSyncID is defined, using value from system parameter
2023-07-17 10:49:08,090 1 INFO BMShieldClient:69 - Initializing BMShieldClient
2023-07-17 10:49:08,091 1 INFO BMShieldClient:760 - baffle.config.path is defined, using value /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-07-17 10:49:08,091 1 INFO BMShieldClient:756 - baffle.ssl.path undefined, loading from default value at /opt/baffle/ssl
2023-07-17 10:49:08,091 1 INFO BMShieldClient:761 - baffle.config.bmShieldSyncID is defined, using value from system parameter
2023-07-17 10:49:08,201 1 INFO BMShieldClient:756 - baffle.config.shieldTag undefined, loading from default value at
2023-07-17 10:49:08,201 1 INFO BMShieldClient:760 - baffle.config.bm.ip is defined, using value dsb-manager-dsb-for-nandini.dsb-roks-vpc-412-c9b7119538b194dae4a1958742b244b0-0000.eu-de.containers.appdomain.cloud
2023-07-17 10:49:08,201 1 INFO BMShieldClient:756 - baffle.config.bm.port undefined, loading from default value at 443
2023-07-17 10:49:08,202 1 INFO BMShieldClient:756 - baffle.config.bm.tenant undefined, loading from default value at ibm
2023-07-17 10:49:08,202 1 INFO BMShieldClient:756 - baffle.config.bm.appID undefined, loading from default value at 64acfabd65fab6124f7872fa
2023-07-17 10:49:08,202 1 INFO BMShieldClient:756 - baffle.config.bm.shieldID undefined, loading from default value at null
2023-07-17 10:49:08,202 1 INFO BMRestClient:58 - Checking BM Connectivity using URL - https://dsb-manager-dsb-for-nandini.dsb-roks-vpc-412-c9b7119538b194dae4a1958742b244b0-0000.eu-de.containers.appdomain.cloud:443/
2023-07-17 10:49:09,225 1 INFO BMShieldClient:795 - baffle.shield.ssl is defined, using value true
2023-07-17 10:49:09,376 1 INFO BMShieldClient:191 - Registration Successful ShieldID =64b3f41765fab6124f78731f
2023-07-17 10:49:09,377 1 INFO BMShieldClient:205 - Getting Shield Initial Configuration
2023-07-17 10:49:09,522 1 INFO BMShieldClient:318 - Downloading Config File : BafflePrivacySchema
2023-07-17 10:49:09,664 1 INFO BMShieldClient:318 - Downloading Config File : BaffleEntitySchema
2023-07-17 10:49:09,803 1 INFO BMShieldClient:318 - Downloading Config File : KmsConfig.properties
2023-07-17 10:49:09,955 1 INFO BMShieldClient:318 - Downloading Config File : BaffleCommonConfig
2023-07-17 10:49:10,101 1 INFO CommonConfig:1156 - Tier: 0
2023-07-17 10:49:10,102 1 INFO CommonConfig:1067 - Nothing to do for the deployment type local
2023-07-17 10:49:10,136 1 INFO KmsConfig:59 - KeyStore type - local
2023-07-17 10:49:10,136 1 INFO KmsConfig:63 - local : Configured application namespace - null
2023-07-17 10:49:10,136 1 INFO KmsConfig:75 - No dek storage module specified. The keys will be in the cache until revoked
2023-07-17 10:49:10,139 1 INFO KmsConfig:59 - KeyStore type - local
2023-07-17 10:49:10,140 1 INFO KmsConfig:63 - local : Configured application namespace - null
2023-07-17 10:49:10,140 1 INFO KmsConfig:75 - No dek storage module specified. The keys will be in the cache until revoked
2023-07-17 10:49:10,141 1 INFO BaffleSecretStoreUtil:587 - No SecretStores configured
2023-07-17 10:49:10,142 1 WARN CommonConfig:1324 - defaulting value of encMode as M_CTR
2023-07-17 10:49:10,142 1 INFO CommonConfig:465 - baffle.shield.ssl is defined, using value true
2023-07-17 10:49:10,143 1 INFO CommonConfig:507 - baffle.shield.keystore is defined, using value /opt/sslconfig/baffleshield-keystore.jks
2023-07-17 10:49:10,143 1 INFO CommonConfig:508 - baffle.shield.keystore.password is defined, using value from system parameter
2023-07-17 10:49:10,143 1 INFO CommonConfig:507 - baffle.shield.truststore is defined, using value /opt/sslconfig/baffleshield-keystore.jks
2023-07-17 10:49:10,143 1 INFO CommonConfig:508 - baffle.shield.truststore.password is defined, using value from system parameter
2023-07-17 10:49:10,143 1 INFO CommonConfig:507 - baffle.shield.ssl.tlsVersion is defined, using value TLSv1.2
2023-07-17 10:49:10,145 1 INFO ConfigReaderUtil:398 - File: /opt/baffle/Release-Baffle.1.7.0.161/shield/BaffleCommonConfig
baffleHeartbeatInterval=30000
....
2023-07-17 10:49:10,146 1 INFO KmsConfig:59 - KeyStore type - local
2023-07-17 10:49:10,146 1 INFO KmsConfig:63 - local : Configured application namespace - null
2023-07-17 10:49:10,146 1 INFO KmsConfig:75 - No dek storage module specified. The keys will be in the cache until revoked
2023-07-17 10:49:10,146 1 INFO KmsConfig:59 - KeyStore type - local
2023-07-17 10:49:10,147 1 INFO KmsConfig:63 - local : Configured application namespace - null
2023-07-17 10:49:10,147 1 INFO KmsConfig:75 - No dek storage module specified. The keys will be in the cache until revoked
2023-07-17 10:49:10,147 1 INFO KmsConfig:59 - KeyStore type - local
2023-07-17 10:49:10,147 1 INFO KmsConfig:63 - local : Configured application namespace - null
2023-07-17 10:49:10,147 1 INFO KmsConfig:75 - No dek storage module specified. The keys will be in the cache until revoked
2023-07-17 10:49:10,149 1 INFO ConfigReaderUtil:398 - File: /opt/baffle/Release-Baffle.1.7.0.161/shield/KmsConfig.properties
baffle_secret=***
kmsType=local

2023-07-17 10:49:10,175 1 INFO CommonConfig:507 - baffle.config.path is defined, using value /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-07-17 10:49:10,176 1 INFO PrivacySchemaReaderToml:106 - Reading from BafflePrivacySchema
2023-07-17 10:49:10,187 1 INFO TomlPrivacySchemaReader:60 - Nothing to encrypt. Empty BafflePrivacySchema
2023-07-17 10:49:10,189 1 INFO PrivacySchemaReaderToml:106 - Reading from BafflePrivacySchema
2023-07-17 10:49:10,189 1 INFO TomlPrivacySchemaReader:60 - Nothing to encrypt. Empty BafflePrivacySchema
2023-07-17 10:49:10,190 1 INFO PrivacySchemaReaderToml:194 - Copying BafflePrivacySchema to .BafflePrivacySchema.Verified
2023-07-17 10:49:10,192 1 INFO BaffleMonitorMetric:42 - Baffle Health Metrics bean registration complete
2023-07-17 10:49:10,288 15 INFO BaffleShield:392 - ************************************************************
2023-07-17 10:49:10,289 15 INFO BaffleShield:393 - ****** BAFFLESHIELD ******
2023-07-17 10:49:10,289 15 INFO BaffleShield:394 - ************************************************************
2023-07-17 10:49:10,289 15 INFO BaffleShield:395 - Deployment type: local
2023-07-17 10:49:10,295 15 INFO CommonConfig:756 - Baffle Release Version: Release-Baffle.1.7.0.161
2023-07-17 10:49:10,295 15 INFO BaffleShield:397 - Parser version: 2.6.5.4-baffle2
2023-07-17 10:49:10,296 15 INFO BaffleShield:398 - JVM bit size: 64
2023-07-17 10:49:10,296 15 INFO BaffleShield:399 - Free memory: 179432360 Total memory: 204472320 Max memory: 3674210304
2023-07-17 10:49:10,296 15 INFO BaffleShield:401 - nofile limit : 1048576
2023-07-17 10:49:10,296 15 INFO BaffleShield:403 - Using OpenSSL version: BoringSSL
2023-07-17 10:49:10,296 15 INFO BaffleShield:412 - Using BaffleCommonConfig at: /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-07-17 10:49:10,296 15 INFO BaffleShield:413 - Using Credential store configuration at: /opt/baffle/Release-Baffle.1.7.0.161/shield/credstore
2023-07-17 10:49:10,297 15 INFO BaffleShield:417 - Proxying *:8444 to f637666e-dc0a-48ac-806d-8e6af4046a2c.c9v3nahd0oekcvsra2t0.databases.appdomain.cloud:31841
2023-07-17 10:49:10,297 15 INFO BaffleShield:437 - BaffleShutdownHook Thread Started
2023-07-17 10:49:10,428 15 INFO CommonConfig:507 - baffle.config.path is defined, using value /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-07-17 10:49:10,428 15 INFO KmsConfig:59 - KeyStore type - local
2023-07-17 10:49:10,428 15 INFO KmsConfig:63 - local : Configured application namespace - null
2023-07-17 10:49:10,428 15 INFO KmsConfig:75 - No dek storage module specified. The keys will be in the cache until revoked
2023-07-17 10:49:10,429 15 INFO ConfigReaderUtil:398 - File: /opt/baffle/Release-Baffle.1.7.0.161/shield/BafflePrivacySchema
format = "TOML"

2023-07-17 10:49:10,429 15 INFO PrivacySchemaReaderToml:106 - Reading from BafflePrivacySchema
2023-07-17 10:49:10,430 15 INFO TomlPrivacySchemaReader:60 - Nothing to encrypt. Empty BafflePrivacySchema
2023-07-17 10:49:10,430 15 INFO TransformDB:460 - Privacy schema update:
2023-07-17 10:49:10,432 15 INFO PrivacySchemaHandler:92 - Starting BafflePrivacySchema Watcher on /opt/baffle/Release-Baffle.1.7.0.161/shield/BafflePrivacySchema
`

@dimakuv
Copy link
Contributor

dimakuv commented Jul 17, 2023

Can you show the docker run command with which you run:

  1. the original app image,
  2. the GSC-generated image

@NandiniKJ
Copy link
Author

Original app image command:
docker run --rm -it -e BM_IP=dsb-manager-dsb-for-nandini.dsb-roks-vpc-412-c9b7119538b194dae4a1958742b244b0-0000.eu-de.containers.appdomain.cloud -e BM_SHIELD_SYNC_ID="*****" -e BM_SHIELD_TAG=dsb-shield-app1 -e BS_SSL=true -e BS_SSL_KEYSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_KEYSTORE_PASSWORD=keystore -e BS_SSL_TRUSTSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_TRUSTSTORE_PASSWORD=keystore -e BS_SSL_TLS_VERSION=TLSv1.2 -e KMS_CONFIG_PROPERTIES="{'baffle_secret':'*****','kmsType': 'local'}" icr.io/data-security-broker/dsb-shield-postgresql-v1:v1

GSC generated image:

docker run --rm -it -e BM_IP=dsb-manager-dsb-for-nandini.dsb-roks-vpc-412-c9b7119538b194dae4a1958742b244b0-0000.eu-de.containers.appdomain.cloud -e BM_SHIELD_SYNC_ID="*****" -e BM_SHIELD_TAG=dsb-shield-app1 -e BS_SSL=true -e BS_SSL_KEYSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_KEYSTORE_PASSWORD=keystore -e BS_SSL_TRUSTSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_TRUSTSTORE_PASSWORD=keystore -e BS_SSL_TLS_VERSION=TLSv1.2 -e KMS_CONFIG_PROPERTIES="{'baffle_secret':'*****','kmsType': 'local'}" --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket gsc-icr.io/data-security-broker/dsb-shield-postgresql-v1:v1

I even tried to run the gsc container command without passing the environment variables.
docker run --device=/dev/sgx_enclave \ -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket \ gsc-icr.io/data-security-broker/dsb-shield-postgresql-v1:v1

@dimakuv
Copy link
Contributor

dimakuv commented Jul 17, 2023

Have you tried to enter this GSC-generated Docker image and take a look around? With a command like:

docker run -it --entrypoint /bin/bash gsc-icr.io/data-security-broker/dsb-shield-postgresql-v1:v1

When you enter the Bash session inside this GSC-generated image, you really don't see the /opt/ directory?

@NandiniKJ
Copy link
Author

I tried to look inside the GSC Docker image, opt folder is there but its empty.

root@baremetal01-innovation-poc-sgx:~/gramine-poc/gsc-v2# docker run -it --entrypoint /bin/bash gsc-icr.io/data-security-broker/dsb-shield-postgresql-v1:v1 root@16ac5039e29b:/# ls bin boot dev etc gramine home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var root@16ac5039e29b:/# cd opt/ root@16ac5039e29b:/opt# ls root@16ac5039e29b:/opt#

@dimakuv
Copy link
Contributor

dimakuv commented Jul 17, 2023

And it's not empty in the original app Docker image? Are you sure? How is this possible...

@NandiniKJ
Copy link
Author

Its not empty in the original Docker image. It has the start-baffle-shield.sh script in the defined path /opt/baffle/Release-Baffle.1.7.0.161/shield.

root@baremetal01-innovation-poc-sgx:~/gramine-poc/gsc-v2# docker exec -it 17e6f3692053 sh sh-4.4$ ls bin boot dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var sh-4.4$ cd opt/ sh-4.4$ ls baffle sslconfig sh-4.4$ cd baffle/ sh-4.4$ sh-4.4$ ls Release-Baffle.1.7.0.161 sh-4.4$ cd Release-Baffle.1.7.0.161/ sh-4.4$ ls migration shield sh-4.4$ cd shield/ sh-4.4$ ls BaffleCommonConfig BafflePrivacySchema baffle-shield-postgresql-final.jar bss_public.pem key_transfer log4j-baffleshield.properties log4j-slf4j-impl-2.17.2.jar start-baffle-shield.sh BaffleEntitySchema KmsConfig.properties bm-connector.jar credstore log4j-api-2.17.2.jar log4j-core-2.17.2.jar logs sh-4.4$

@dimakuv
Copy link
Contributor

dimakuv commented Jul 17, 2023

But you performed docker exec -it 17e6f3692053, i.e., you connected to an already-existing Docker container. Could it be that in this container, you or some script created the /opt/ contents?

What if you just do:

docker run -it --entrypoint /bin/bash icr.io/data-security-broker/dsb-shield-postgresql-v1:v1

@NandiniKJ
Copy link
Author

I tried the above command which you gave, the existing image has the baffle folder inside opt.

root@baremetal01-innovation-poc-sgx:~/gramine-poc/gsc-v2# docker run -it --entrypoint /bin/bash icr.io/data-security-broker/dsb-shield-postgresql:v1 [baffle@b0c3229b9f8a /]$ ls bin boot dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var [baffle@b0c3229b9f8a /]$ cd opt/ [baffle@b0c3229b9f8a opt]$ ls baffle sslconfig [baffle@b0c3229b9f8a opt]$ cd baffle [baffle@b0c3229b9f8a baffle]$ ls Release-Baffle.1.7.0.161 [baffle@b0c3229b9f8a baffle]$ cd Release-Baffle.1.7.0.161/ [baffle@b0c3229b9f8a Release-Baffle.1.7.0.161]$ cd shield/ [baffle@b0c3229b9f8a shield]$ ls baffle-shield-postgresql-final.jar bss_public.pem log4j-api-2.17.2.jar log4j-core-2.17.2.jar start-baffle-shield.sh bm-connector.jar key_transfer log4j-baffleshield.properties log4j-slf4j-impl-2.17.2.jar [baffle@b0c3229b9f8a shield]$

@dimakuv
Copy link
Contributor

dimakuv commented Jul 17, 2023

This makes no sense to me...

Could you:

  1. Remove all Docker images, containers, etc. -- basically prune all Docker artifacts
  2. Remove the build/ directory in GSC -- prune all GSC-temporary data
  3. Re-run gsc build and gsc sign-image commands and attach the produced logs

In other words, re-do the whole GSC process from an absolutely clean state, and show us the logs.

@NandiniKJ
Copy link
Author

I deleted all the Docker images and pruned it. Git cloned - https://github.com/gramineproject/gsc.git
Then ran the following commands:

cd gsc cp config.yaml.template config.yaml openssl genrsa -3 -out enclave-key.pem 3072 ./gsc build --insecure-args icr.io/data-security-broker/dsb-shield-postgresql:v1 test/generic.manifest

This time the build failed in Step 9. Please find the build output below.

`Step 9/29 : RUN cd /gramine && meson setup build/ --prefix="/gramine/meson_build_output" --buildtype=release -Ddirect=enabled -Dsgx=enabled -Ddcap=enabled -Dsgx_driver=upstream -Dsgx_driver_include_path=/gramine/driver && ninja -C build && ninja -C build install

---> Running in 319df51f93e9
The Meson build system
Version: 1.2.0
Source dir: /gramine
Build dir: /gramine/build
Build type: native build
Project name: gramine
Project version: 1.5postUNRELEASED
C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1
20.04.1) 9.4.0")
C linker for the host machine: cc ld.bfd 2.34
C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
C++ linker for the host machine: c++ ld.bfd 2.34
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program check-no-reloc.sh found: YES (/gramine/scripts/check-no-reloc.sh)
Program gen-pal-map.py found: YES (/gramine/scripts/gen-pal-map.py)
Program get-python-platlib.py found: YES (/gramine/scripts/get-python-platlib.py)
Program meson-clang-format.sh found: YES (/gramine/scripts/meson-clang-format.sh)
Fetching value of define "GLIBC" : 2
Program objcopy found: YES (/usr/bin/objcopy)
Program python3 found: YES (/usr/bin/python3)
WARNING: You should add the boolean check kwarg to the run_command call.
.......
cc common.o onefile.o fuzz_dtlsserver.o ../../tests/src/helpers.o ../../tests/src/bignum_helpers.o ../../tests/src/asn1_helpers.o ../../tests/src/psa_crypto_helpers.o ../../tests/src/psa_exercise_key.o ../../tests/src/threading_helpers.o ../../tests/src/random.o ../../tests/src/fake_external_rng_for_test.o ../../tests/src/certs.o ../../tests/src/drivers/test_driver_aead.o ../../tests/src/drivers/test_driver_asymmetric_encryption.o ../../tests/src/drivers/test_driver_pake.o ../../tests/src/drivers/test_driver_key_agreement.o ../../tests/src/drivers/test_driver_signature.o ../../tests/src/drivers/test_driver_key_management.o ../../tests/src/drivers/test_driver_cipher.o ../../tests/src/drivers/hash.o ../../tests/src/drivers/test_driver_mac.o ../../tests/src/drivers/platform_builtin_keys.o -L../../library -lmbedtls -lmbedx509 -lmbedcrypto -o fuzz_dtlsserver
make[2]: Leaving directory '/gramine/build/subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a.p/programs/fuzz'
make[1]: Leaving directory '/gramine/build/subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a.p/programs'
make: Leaving directory '/gramine/build/subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a.p'

  • basename subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a
  • cp -a subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a.p/library/libmbedcrypto.a subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a
  • basename subprojects/mbedtls-mbedtls-3.4.0/libmbedtls.a
  • cp -a subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a.p/library/libmbedtls.a subprojects/mbedtls-mbedtls-3.4.0/libmbedtls.a
  • basename subprojects/mbedtls-mbedtls-3.4.0/libmbedx509.a
  • cp -a subprojects/mbedtls-mbedtls-3.4.0/libmbedcrypto.a.p/library/libmbedx509.a subprojects/mbedtls-mbedtls-3.4.0/libmbedx509.a
    ninja: build stopped: subcommand failed.
    Failed to build unsigned graminized Docker image gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1-unsigned.`

@aneessahib
Copy link
Contributor

aneessahib commented Jul 18, 2023

What you are now seeing is another new issue.

Please change this line to the below, and retry.

&& /usr/bin/python3 -B -m pip install 'tomli>=1.1.0' 'tomli-w>=0.4.0' 'meson==1.1.1'

@NandiniKJ
Copy link
Author

I tried the above fix and the ninja issue is resolved, but got into another error.

`Step 12/29 : RUN apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install -y binutils expect libprotobuf-c-dev locales openssl python3 python3-cryptography python3-protobuf python3-pyelftools \python3-pip && /usr/bin/python3 -B -m pip install click jinja2 protobuf 'tomli>=1.1.0' 'tomli-w>=0.4.0' && apt-get remove -y python3-pip && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

---> Running in 030aed51b7a5
/bin/sh: apt-get: command not found

Failed to build unsigned graminized Docker image gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1-unsigned.`

@aneessahib
Copy link
Contributor

What's the distro of your base image?

@NandiniKJ
Copy link
Author

Please find the details below:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL=https://www.ubuntu.com/
SUPPORT_URL=https://help.ubuntu.com/
BUG_REPORT_URL=https://bugs.launchpad.net/ubuntu/
PRIVACY_POLICY_URL=https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
UBUNTU_CODENAME=jammy

Gramine does not yet support Ubuntu 22.04, though the support will be merged shortly, probably next week. In the meantime, you can try this PR…

https://github.com/gramineproject/gsc/pull/155

@aneessahib
Copy link
Contributor

So are you already using the mentioned PR? #155 ?

@NandiniKJ
Copy link
Author

Yes, even after using this PR I get the below error.

`Step 12/29 : RUN apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install -y binutils expect libprotobuf-c-dev locales openssl python3 python3-cryptography python3-protobuf python3-pyelftools \python3-pip && /usr/bin/python3 -B -m pip install click jinja2 protobuf 'tomli>=1.1.0' 'tomli-w>=0.4.0' && apt-get remove -y python3-pip && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

---> Running in 030aed51b7a5
/bin/sh: apt-get: command not found

Failed to build unsigned graminized Docker image gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1-unsigned.`

@aneessahib
Copy link
Contributor

please paste the contents of your config.yaml file here

@NandiniKJ
Copy link
Author

Please find the contents below.

# Specify the OS distro that is used to build Gramine, i.e., the distro from where the Gramine build
# gets all tools and dependencies from. This distro should match the distro underlying the
# application's Docker image; otherwise the results may be unpredictable.
#
# Currently supported distros are:
# - ubuntu:20.04, ubuntu:21.04, ubuntu:22.04
# - debian:10, debian:11, debian:12
# - centos:8
Distro: "ubuntu:22.04"

# If the image has a specific registry, define it here.
# Empty by default; example value: "registry.access.redhat.com/ubi8".
Registry: ""

# If you're using your own fork and branch of Gramine, specify the GitHub link and the branch name
# below; typically, you want to keep the default values though.
#
# It is also possible to specify the prebuilt Gramine Docker image (that was built previously via
# the `gsc build-gramine` command). For this, remove Repository and Branch and instead write:
#   Image:      "<prebuilt Gramine Docker image>"
#
# GSC releases are guaranteed to work with corresponding Gramine releases (and GSC `master`
# branch is guaranteed to work with current Gramine `master` branch).
Gramine:
    Repository: "https://github.com/gramineproject/gramine.git"
    Branch:     "master"

# Specify the Intel SGX driver installed on your machine (more specifically, on the machine where
# the graminized Docker container will run); there are several variants of the SGX driver:
#
#   - upstream (in-kernel) driver: use empty values like below
#         Repository: ""
#         Branch:     ""
#
#   - DCAP out-of-tree driver: same as above, use empty values
#         Repository: ""
#         Branch:     ""
#
#   - legacy out-of-tree driver: use something like the below values, but adjust the branch name
#         Repository: "https://github.com/01org/linux-sgx-driver.git"
#         Branch:     "sgx_driver_1.9"
#
SGXDriver:
    Repository: ""
    Branch:     ""

@aneessahib
Copy link
Contributor

Please take out all the redundant comments. What's the Python version of your base image, and GSC image

@NandiniKJ
Copy link
Author

My base image doesn't have Python installed on it. I have attached the Distro of base image and GSC image.

Base image:
`root@baremetal01-innovation-poc-sgx:~/gramine/gsc# docker run -it --entrypoint /bin/bash icr.io/data-security-broker/dsb-shield-postgresql:v1
[baffle@9943670ad863 /]$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.8 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.8
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.8"
[baffle@9943670ad863 /]$ `

GSC image:

root@baremetal01-innovation-poc-sgx:~/gramine/gsc# docker run -it --entrypoint /bin/bash gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1 root@0c8fde87c67b:/# cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy

@aneessahib
Copy link
Contributor

aneessahib commented Jul 18, 2023

Ok so that's the issue. Your base image distro is RHEL 8(and not Ubuntu 22.04 as mentioned earlier). The GSC supported distros are called out in the config.yaml file. For now, you can try setting the distro in the config.yaml to centos:8 and retry.

@NandiniKJ
Copy link
Author

I tried to change the distro to centos:8 in config.yaml file and then build it using ./gsc build --insecure-args icr.io/data-security-broker/dsb-shield-postgresql:v1 test/generic.manifest command. Got the following error.

` ---> 4a357a2376f9
Step 10/24 : RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* && sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-Linux-PowerTools.repo

---> Running in 776215230c73
sed: can't read /etc/yum.repos.d/CentOS-Linux-*: No such file or directory

Failed to build unsigned graminized Docker image gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1-unsigned.`

@aneessahib
Copy link
Contributor

GSC does not support RHEL at this point. But Gramine packages for RHEL are available, so you could consider building an image by installing RHEL packages. Another option is to move to one of the supported distros, does that work for you? If no other options, then we will have to look at taking this as a feature request. @dimakuv - any other ideas?

@NandiniKJ
Copy link
Author

Can you explain how to build an image by installing RHEL packages. Will this option run inside GSC or Gramine directly.

Moving to other distros is not an option because this is a third party application.

@aneessahib
Copy link
Contributor

We will revert with a simple script to run a helloworld program in a RHEL container with Gramine.

@NandiniKJ
Copy link
Author

Ok thanks.

@NandiniKJ
Copy link
Author

Just wanted to check - my host OS is ubuntu and the application base image is RHEL. Will this work wrt GSC ? If not then which image is the issue here and needs to be changed to what.

@sahason
Copy link
Contributor

sahason commented Jul 28, 2023

@NandiniKJ Please modify JAVA_HOME as loader.env.JAVA_HOME = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/

The LD_LIBRARY_PATH that you have set there is 'j' missing in ava-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64. Could you please modify this as well?

@NandiniKJ
Copy link
Author

@sahason Please find the manifest file below.

loader.entrypoint = "file:/gramine/meson_build_output/lib64/gramine/libsysdb.so" loader.env.LD_LIBRARY_PATH = "/gramine/meson_build_output/lib64/gramine/runtime/glibc:/usr/lib64:{{"{{library_paths}}"}}:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64" loader.env.LD_PRELOAD = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so" loader.env.JAVA_HOME = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/"

Still getting the same error:

Error: could not find libjava.so Error: Could not find Java SE Runtime Environment.

@NandiniKJ
Copy link
Author

NandiniKJ commented Jul 28, 2023

@SonaliSaha Java path is already set in manifest file. I also added LD_PRELOAD for libjava.so.

loader.entrypoint = "file:/gramine/meson_build_output/lib64/gramine/libsysdb.so" loader.env.LD_LIBRARY_PATH = "/gramine/meson_build_output/lib64/gramine/runtime/glibc:/usr/lib64:{{"{{library_paths}}"}}:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/bin" loader.env.LD_PRELOAD = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/libjava.so" loader.env.JAVA_HOME = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64"

Getting the same ereor:

Error: could not find libjava.so Error: Could not find Java SE Runtime Environment.

@sahason
Copy link
Contributor

sahason commented Aug 1, 2023

@NandiniKJ Could you please share a minimal docker image/Dockerfile where I can repro the issue along with manifest? It will help to debug further.

@NandiniKJ
Copy link
Author

@sahason I cannot share the docker image/Dockerfile as it is proprietary third party application. Can you pls confirm which version and flavour of Java does Gramine support.

@sahason
Copy link
Contributor

sahason commented Aug 3, 2023

@NandiniKJ Could you please send the output of below commands by running inside the GSC container?

  1. java --version
  2. find / -name libjava.so

@NandiniKJ
Copy link
Author

@sahason Please find the details below.

root@baremetal01-innovation-poc-sgx:~# docker run --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket -it --entrypoint /bin/bash gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1 [baffle@0c95ae096afe /]$ java -version openjdk version "1.8.0_382" OpenJDK Runtime Environment (build 1.8.0_382-b05) OpenJDK 64-Bit Server VM (build 25.382-b05, mixed mode) [baffle@0c95ae096afe /]$ find / -name libjava.so find: ‘/var/cache/yum/metadata/ubi-8-baseos-rpms-8-x86_64/gpgdir/private-keys-v1.d’: Permission denied find: ‘/var/cache/yum/metadata/CentOSAppStream-8-x86_64/gpgdir/private-keys-v1.d’: Permission denied find: ‘/var/cache/yum/metadata/epel-8-x86_64/gpgdir/private-keys-v1.d’: Permission denied find: ‘/var/cache/yum/metadata/CentosBaseOS-8-x86_64/gpgdir/private-keys-v1.d’: Permission denied find: ‘/var/cache/yum/metadata/ubi-8-appstream-rpms-8-x86_64/gpgdir/private-keys-v1.d’: Permission denied find: ‘/var/cache/yum/metadata/ubi-8-codeready-builder-rpms-8-x86_64/gpgdir/private-keys-v1.d’: Permission denied find: ‘/var/cache/ldconfig’: Permission denied find: ‘/proc/tty/driver’: Permission denied /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/libjava.so find: ‘/root’: Permission denied find: ‘/lost+found’: Permission denied [baffle@0c95ae096afe /]$

@sahason
Copy link
Contributor

sahason commented Aug 3, 2023

@NandiniKJ output of sudo find / -name libjava.so

@NandiniKJ
Copy link
Author

NandiniKJ commented Aug 3, 2023

@sahason Sudo command not found error

[baffle@0c95ae096afe /]$ sudo find / -name libjava.so bash: sudo: command not found [baffle@0c95ae096afe /]$

Screenshot 2023-08-03 at 1 02 16 PM

@sahason
Copy link
Contributor

sahason commented Aug 3, 2023

@NandiniKJ I could repro the issue in my system with a custom image. After adding the below lines to the manfest file the issue got resolved.

loader.env.LD_PRELOAD = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/lib/amd64/jli/libjli.so:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/libjava.so"

loader.env.JAVA_HOME = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64"

If you already have these lines added to the manifest could you try removing any other entries for OpenJDK from LD_LIBRARY_PATH, LD_PRELOAD etc?

Also, you mentioned you could append LD_LIBRARY_PATH. How are you doing it? I get GSC build errors when I try to add an entry for LD_LIBRARY_PATH. Is it possible for you to share your manifest file?

Could you please share your build steps?

@NandiniKJ
Copy link
Author

@sahason Can you please confirm whether you made the above changes in entrypoint.manifest.template or entrypoint.common.manifest.template

@sahason
Copy link
Contributor

sahason commented Aug 3, 2023

@NandiniKJ You should not modify these files. You must be building with this command gsc build [OPTIONS] <APP.MANIFEST>. Please check . I am using this command to build ./gsc build --insecure-args my-java-app test/generic.manifest and added the lines to test/generic.manifest. You can create a specific manifest file for your workload.

@NandiniKJ
Copy link
Author

I tried the changes and this is the output:

`root@baremetal01-innovation-poc-sgx:~/gramine/gsc-rhel/gsc# docker run --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")'
Gramine is starting. Parsing TOML manifest file, this may take some time...

Gramine detected the following insecure configurations:

  • loader.insecure__use_cmdline_argv = true (forwarding command-line args from untrusted host to the app)

Gramine will continue application execution, but this configuration must not be used in production!

ERROR: ld.so: object '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/lib/amd64/jli/libjli.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
/gramine/app_files/sh: error while loading shared libraries: libjvm.so: cannot open shared object file: No such file or directory
root@baremetal01-innovation-poc-sgx:/gramine/gsc-rhel/gsc# vi templates/ubi/entrypoint.manifest.template
root@baremetal01-innovation-poc-sgx:
/gramine/gsc-rhel/gsc# docker run --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket -it --entrypoint /bin/bash gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1
[baffle@89d430a1ae22 /]$ find / -name libjava.so
find: ‘/var/cache/ldconfig’: Permission denied
find: ‘/proc/tty/driver’: Permission denied
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/libjava.so
find: ‘/root’: Permission denied
find: ‘/lost+found’: Permission denied
[baffle@89d430a1ae22 /]$ find / -name libjli.so
find: ‘/var/cache/ldconfig’: Permission denied
find: ‘/proc/tty/driver’: Permission denied
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so
find: ‘/root’: Permission denied
find: ‘/lost+found’: Permission denied
[baffle@89d430a1ae22 /]$ cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64
[baffle@89d430a1ae22 java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64]$ ls
jre
[baffle@89d430a1ae22 java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64]$
`

The path of libjli.so and libjava.so is different in my Docker image, its inside jre folder - /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so and /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/libjava.so

@sahason
Copy link
Contributor

sahason commented Aug 3, 2023

Ok. So the libjava.so error is gone now. The libjava.so path is same for us. Please use the path that is valid for you for libjli and the error related to this will be gone.

Now you are seeing this error error while loading shared libraries: libjvm.so: cannot open shared object file: No such file or directory.

For this kind of error please find the path for the library in the image and add it to laoder.env.LD_PRELOAD .

@NandiniKJ
Copy link
Author

@sahason I have updated the path accordingly, if I add the libjvm.so path to loader.env.LD_PRELOAD then I get the same error like before.

Error: could not find libjava.so Error: Could not find Java SE Runtime Environment.

libjvm.so path has to be added to loader.env.LD_LIBRARY_PATH, but I get build errors when I try to add this.

Building unsigned graminized Docker image gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1-unsignedfrom original application imageicr.io/data-security-broker/dsb-shield-postgresql:v1... Traceback (most recent call last): File "/root/gramine/gsc-rhel/gsc/./gsc", line 12, in <module> sys.exit(main(sys.argv)) File "/root/gramine/gsc-rhel/gsc/./gsc.py", line 554, in main return args.command(args) File "/root/gramine/gsc-rhel/gsc/./gsc.py", line 269, in gsc_build merged_manifest_dict = merge_two_dicts(user_manifest_dict, entrypoint_manifest_dict) File "/root/gramine/gsc-rhel/gsc/./gsc.py", line 167, in merge_two_dicts merge_two_dicts(dict1[key], dict2[key], path + [str(key)]) File "/root/gramine/gsc-rhel/gsc/./gsc.py", line 167, in merge_two_dicts merge_two_dicts(dict1[key], dict2[key], path + [str(key)]) File "/root/gramine/gsc-rhel/gsc/./gsc.py", line 173, in merge_two_dicts raise Exception(f'''Duplicate key with different values found: {".".join(path +
Exception: Duplicate key with different values found: `loader.env.LD_LIBRARY_PATH``

@sahason
Copy link
Contributor

sahason commented Aug 4, 2023

@NandiniKJ Could you please use OpenJDK 11 instead OpenJDK 8 in your base image?

@sahason
Copy link
Contributor

sahason commented Aug 11, 2023

@NandiniKJ To use OpenJDK 8 could you please pull the latest changes from https://github.com/sahason/gsc/tree/sahason/gsc-rhel8-support and give it a try? You need to add this line RUN ln -s /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre /usr/jre to your dockerfile or create a wrapper. Please revert back any changes regarding LD_PRELOAD/PATH/LD_LIBRARY_PATH from templates and manifest.

@sahason
Copy link
Contributor

sahason commented Aug 17, 2023

@NandiniKJ Could you please pull the latest changes from this branch https://github.com/sahason/gsc/tree/sahason/gsc-rhel8-support? Now you don't need to modify anything in your base image Dockerfile. The only change you need to make is add an entry of LD_PRELOAD for libjli.so in your app manifest.

@NandiniKJ
Copy link
Author

NandiniKJ commented Aug 17, 2023

@sahason Thank you so much, I will try this solution and update you in sometime.

@NandiniKJ
Copy link
Author

@sahason Got the below error:

ERROR: ld.so: object '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/lib/amd64/jli/libjli.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

@sahason
Copy link
Contributor

sahason commented Aug 18, 2023

@NandiniKJ From your earlier comments I see that libjli.so is present in this path /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so. It is inside jre folder.

Please modify your manifest with loader.env.LD_PRELOAD = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so" and try again.

@aneessahib
Copy link
Contributor

@NandiniKJ From your earlier comments I see that libjli.so is present in this path /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so. It is inside jre folder.

Please modify your manifest with loader.env.LD_PRELOAD = "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-2.el8.x86_64/jre/lib/amd64/jli/libjli.so" and try again.

@NandiniKJ - have you tried this?

@NandiniKJ
Copy link
Author

Hi @aneessahib, After taking the latest pull and making changes in the manifest file, I'm getting the below error.

root@baremetal01-innovation-poc-sgx:~/gramine/gsc-rhel/gsc# docker run --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")' Gramine is starting. Parsing TOML manifest file, this may take some time... error: Cannot open /dev/sgx_enclave (permission denied). This may happen because the current user has insufficient permissions to this device. error: load_enclave() failed with error: Permission denied (EACCES)

@sahason
Copy link
Contributor

sahason commented Aug 24, 2023

@NandiniKJ Please run this command sudo chmod 777 /dev/sgx_* and try again.

@NandiniKJ
Copy link
Author

@sahason Please find the output below.

`root@baremetal01-innovation-poc-sgx:~/gramine/gsc-rhel/gsc# docker run --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")'
Gramine is starting. Parsing TOML manifest file, this may take some time...

Gramine detected the following insecure configurations:

  • loader.insecure__use_cmdline_argv = true (forwarding command-line args from untrusted host to the app)

Gramine will continue application execution, but this configuration must not be used in production!

Unrecognized option: -c
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.`

@sahason
Copy link
Contributor

sahason commented Aug 24, 2023

@NandiniKJ Could you please run this command natively (without gsc) and share the output?
docker run icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")'

@NandiniKJ
Copy link
Author

When I try to run the above docker command, got the below output.

`root@baremetal01-innovation-poc-sgx:~# docker run icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")'

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/baffle/Release-Baffle.1.7.0.161/shield/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/baffle/Release-Baffle.1.7.0.161/shield/bm-connector.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
2023-08-24 07:27:11,320 1 ERROR CommonConfig:573 - File BaffleCommonConfig is missing from path /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-08-24 07:27:11,321 1 ERROR CommonConfig:574 - java.lang.RuntimeException: File BaffleCommonConfig is missing from path /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-08-24 07:27:11,321 1 ERROR CommonConfig:1129 - java.lang.RuntimeException: File BaffleCommonConfig is missing from path /opt/baffle/Release-Baffle.1.7.0.161/shield
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: File BaffleCommonConfig is missing from path /opt/baffle/Release-Baffle.1.7.0.161/shield
at io.baffle.blind.CommonConfig.initializeStaticParameters(CommonConfig.java:1133)
at io.baffle.blind.CommonConfig.initialize(CommonConfig.java:823)
at io.baffle.blind.CommonConfig.(CommonConfig.java:313)
at io.baffle.blind.CommonConfig.getInstance(CommonConfig.java:631)
at io.baffle.blind.CommonConfig.getInstance(CommonConfig.java:626)
at io.baffle.sdk.databases.DBProperties.initialize(DBProperties.java:89)
at io.baffle.shield.sql.postgresql.BaffleShield.(BaffleShield.java:65)`

I'm able to run the docker image by passing the environment variables.

docker run --rm -e BM_IP=************ -e BM_SHIELD_SYNC_ID=************** -e BM_SHIELD_TAG=dsb-shield-app1 -e BS_SSL=true -e BS_SSL_KEYSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_KEYSTORE_PASSWORD=keystore -e BS_SSL_TRUSTSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_TRUSTSTORE_PASSWORD=keystore -e BS_SSL_TLS_VERSION=TLSv1.2 -e KMS_CONFIG_PROPERTIES="{'baffle_secret':'******','kmsType': 'local'}" icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")'

Output:

`root@baremetal01-innovation-poc-sgx:~# docker run --rm -e BM_IP=dsb-manager-dsb-for-nandini.dsb-roks-vpc-412-c9b7119538b194dae4a1958742b244b0-0000.eu-de.containers.appdomain.cloud -e BM_SHIELD_SYNC_ID=IyNTSElFTEQjI2RzYi1uZ2lueCMjNDQzIyNpYm0jIzY0YWNmYWJkNjVmYWI2MTI0Zjc4NzJmYSMjODQ0NCMjMTJhM2ZkZDA0ZTdlYWEzODcxZGY5ODFjYzNmNWE0Njg3NDk2NjMyZWIwMzZjZTY3NjM3OWQ4YTQ3NjY1ZTlkMw== -e BM_SHIELD_TAG=dsb-shield-app1 -e BS_SSL=true -e BS_SSL_KEYSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_KEYSTORE_PASSWORD=keystore -e BS_SSL_TRUSTSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_TRUSTSTORE_PASSWORD=keystore -e BS_SSL_TLS_VERSION=TLSv1.2 -e KMS_CONFIG_PROPERTIES="{'baffle_secret':'123456','kmsType': 'local'}" icr.io/data-security-broker/dsb-shield-postgresql:v1 -c 'print("HelloWorld!")'

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/baffle/Release-Baffle.1.7.0.161/shield/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/baffle/Release-Baffle.1.7.0.161/shield/bm-connector.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
2023-08-24 07:28:33,438 1 INFO CommonConfig:508 - baffle.config.bmShieldSyncID is defined, using value from system parameter
2023-08-24 07:28:33,442 1 INFO BMShieldClient:69 - Initializing BMShieldClient
2023-08-24 07:28:33,442 1 INFO BMShieldClient:760 - baffle.config.path is defined, using value /opt/baffle/Release-Baffle.1.7.0.161/shield
2023-08-24 07:28:33,442 1 INFO BMShieldClient:756 - baffle.ssl.path undefined, loading from default value at /opt/baffle/ssl
2023-08-24 07:28:33,442 1 INFO BMShieldClient:761 - baffle.config.bmShieldSyncID is defined, using value from system parameter
2023-08-24 07:28:33,524 1 INFO BMShieldClient:756 - baffle.config.shieldTag undefined, loading from default value at
2023-08-24 07:28:33,524 1 INFO BMShieldClient:760 - baffle.config.bm.ip is defined, using value dsb-manager-dsb-for-nandini.dsb-roks-vpc-412-c9b7119538b194dae4a1958742b244b0-0000.eu-de.containers.appdomain.cloud
2023-08-24 07:28:33,525 1 INFO BMShieldClient:756 - baffle.config.bm.port undefined, loading from default value at 443
2023-08-24 07:28:33,525 1 INFO BMShieldClient:756 - baffle.config.bm.tenant undefined, loading from default value at ibm
2023-08-24 07:28:33,525 1 INFO BMShieldClient:756 - baffle.config.bm.appID undefined, loading from default value at 64acfabd65fab6124f7872fa
`

@sahason
Copy link
Contributor

sahason commented Aug 24, 2023

@NandiniKJ Could you please pass the same environment variables for running GSC image and share the ouput. You need to add this line loader.insecure__use_host_env = true in manifest. This is insecure, for production environment follow this link https://gramine.readthedocs.io/en/stable/manifest-syntax.html#environment-variables.

@NandiniKJ
Copy link
Author

@sahason Made the above chaages and got the following output.

`root@baremetal01-innovation-poc-sgx:~/gramine/gsc-rhel/gsc# docker run --rm -e BM_IP=******* -e BM_SHIELD_SYNC_ID=******** -e BM_SHIELD_TAG=dsb-shield-app1 -e BS_SSL=true -e BS_SSL_KEYSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_KEYSTORE_PASSWORD=keystore -e BS_SSL_TRUSTSTORE_FILE=/opt/sslconfig/baffleshield-keystore.jks -e BS_SSL_TRUSTSTORE_PASSWORD=keystore -e BS_SSL_TLS_VERSION=TLSv1.2 -e KMS_CONFIG_PROPERTIES="{'baffle_secret':'*****','kmsType': 'local'}" --device=/dev/sgx_enclave -v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket gsc-icr.io/data-security-broker/dsb-shield-postgresql:v1
Gramine is starting. Parsing TOML manifest file, this may take some time...

Gramine detected the following insecure configurations:

  • loader.insecure__use_cmdline_argv = true (forwarding command-line args from untrusted host to the app)
  • loader.insecure__use_host_env = true (forwarding environment vars from untrusted host to the app)

Gramine will continue application execution, but this configuration must not be used in production!

Unrecognized option: -c
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
root@baremetal01-innovation-poc-sgx:~/gramine/gsc-rhel/gsc# `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants