Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2023-32303: enforce restricting secret file permissions to user read/write · planetlabs/planet-client-python@d71415a

Planet is software that provides satellite data. The secret file stores the user’s Planet API authentication information. It should only be accessible by the user, but before version 2.0.1, its permissions allowed the user’s group and non-group to read the file as well. This issue was patched in version 2.0.1. As a workaround, set the secret file permissions to only user read/write by hand.

CVE
#js#auth

Expand Up @@ -19,15 +19,16 @@ import logging import os import pathlib import stat import typing from typing import Optional
import httpx import jwt
from . import http from .constants import ENV_API_KEY, PLANET_BASE_URL, SECRET_FILE_PATH from .exceptions import AuthException from typing import Optional
LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -226,8 +227,15 @@ def value(self):
class _SecretFile:
def __init__(self, path): self.path = path def __init__(self, path: typing.Union[str, pathlib.Path]): self.path = pathlib.Path(path)
self.permissions = stat.S_IRUSR | stat.S_IWUSR # user rw
# in sdk versions <=2.0.0, secret file was created with the wrong # permissions, fix this automatically as well as catching the unlikely # cases where the permissions get changed externally self._enforce_permissions()
def write(self, contents: dict): try: Expand All @@ -240,11 +248,29 @@ def write(self, contents: dict):
def _write(self, contents: dict): LOGGER.debug(f’Writing to {self.path}’) with open(self.path, ‘w’) as fp:
def opener(path, flags): return os.open(path, flags, self.permissions)
with open(self.path, ‘w’, opener=opener) as fp: fp.write(json.dumps(contents))
def read(self) -> dict: LOGGER.debug(f’Reading from {self.path}’) with open(self.path, ‘r’) as fp: contents = json.loads(fp.read()) return contents
def _enforce_permissions(self): ‘’’if the file’s permissions are not what they should be, fix them’’’ try: # in octal, permissions is the last three bits of the mode file_permissions = self.path.stat().st_mode & 0o777 if file_permissions != self.permissions: LOGGER.debug( f’{self.path} permissions are {oct(file_permissions)}, ' f’should be {oct(self.permissions)}. Fixing.’) self.path.chmod(self.permissions) except FileNotFoundError: # just skip it if the secret file doesn’t exist pass

Related news

GHSA-j5fj-rfh6-qj85: Planet's secret file is created with excessive permissions

### Impact The secret file stores the user's Planet API authentication information. It should only be accessible by the user, but its permissions allowed the user's group and non-group to read the file as well. ### Validation Check the permissions on the secret file with `ls -l ~/.planet.json` and ensure that they read as `-rw-------` ### Patches [d71415a8](https://github.com/planetlabs/planet-client-python/commit/d71415a83119c5e89d7b80d5f940d162376ee3b7) ### Workarounds Set the secret file permissions to only user read/write by hand: ``` chmod 600 ~/.planet.json ```

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907