nasa / fprime

F´ - A flight software and embedded systems framework
https://fprime.jpl.nasa.gov
Apache License 2.0
10.02k stars 1.29k forks source link

`Svc/FileUplink` - Update file uplink file path handling #2601

Open timcanham opened 5 months ago

timcanham commented 5 months ago
F´ Version 3.4.3
Affected Component Svc/FileUplink

Feature Description

Change the file path handling for Svc/FileUplink to make it relative to a supplied path.

Rationale

The current implementation is a security/safety risk, since it uses the pathname as is, including root / paths. This can make the vehicle vulnerable to invalid/nefarious pathnames. Change the implementation to:

1) Take a base pathname as part of a configure() function. 2) Normalize the file paths for uplinked files to avoid ../ tricks. 3) Write files to path relative to provided base, creating directories as needed.

Joshua-Anderson commented 5 months ago

A few thoughts:

Instead of adding additional capabilities to FileUplink, I think it may make more sense to rely on operating system provided filesystem permissions and read-only partitions to protect the FSW from overwriting critical files. This provides the secondary benefit of preventing all fprime components from damaging critical files, not just FileUplink

LeStarch commented 5 months ago

@bitWarrior would you weigh-in here?