about summary refs log tree commit diff stats
path: root/src/liolib.c
Commit message (Collapse)AuthorAgeFilesLines
* disallow all relative paths (./ or ../)Kartik K. Agaram2022-03-201-1/+5
| | | | | | | | | Teliva's model doesn't include any way to change directory. We just have relative paths and absolute paths. Relative paths should not be able to reach into parent directories. The current test is a bit hacky; it also disallows directories ending in a period. Hopefully not an issue.
* protect framework files from appsKartik K. Agaram2022-03-081-3/+12
| | | | | | | | There's a separate open question here of where Teliva should store files like teliva_editor_state and teliva_editor_buffer. One school of thought is that apps should never be dropping crud into people's directories. On the other hand, I'm kinda encouraging people so far to just run apps from Teliva's directory. Perhaps that makes it ok?
* just always temp files to be createdKartik K. Agaram2022-03-071-1/+3
| | | | | Implication: os.rename now needs to be sandboxed. Hopefully it's tractable to treat it as conceptually identical to opening two files.
* purge all support for per-function permissionsKartik K. Agaram2022-03-071-19/+2
| | | | | | | | | We're now back to the problem of how to transparently allow Teliva to create temporary filenames without every app having to explicitly allow them. I think I may need to define start_writing in C, so that it can use a non-sandboxed version of io.open.
* hokey primitive to create temporary fileKartik K. Agaram2022-03-071-0/+3
| | | | | | | | | | | | | | The trouble with os.tmpname() is that it always creates in /tmp. If /tmp is in a different volume from our real filename, os.rename() will fail. This new primitive doesn't support primitive paths yet. I'm also again nervous about the security implications of my whole approach. What if we create an inner function called start_writing? Would we be able to do anything inside it? I'm starting to suspect this whole approach of going by caller name is broken. An app could also create inner functions called 'main'..
* zet.tlv: switch file writes to new APIKartik K. Agaram2022-03-071-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The interface for apps looks much nicer now, see 'main' in zet.tlv. However there are some open issues: - It can still be confusing to the computer owner that an app tries to write to some temporary file that isn't mentioned anywhere. - File renames can fail if /tmp is on a different volume. - What happens if an app overrides start_writing()? The computer owner may think they've audited the caller of start_writing and give it blanket file permissions. Teliva tunnels through start_writing when computing the caller. If the app can control what start_writing does, the app could be performing arbitrary malicious file operations. Right now things actually seem perfectly secure. Overriding start_writing has no effect. Our approach for loading .tlv files (in reverse chronological order, preventing older versions from overriding newer ones) has the accidentally _great_ property that Teliva apps can never override system definitions. So we have a new reason to put standard libraries in a .lua file: if we need to prevent apps from overriding it. This feels like something that needs an automated test, both to make sure I'm running the right experiment and to ensure I don't accidentally cause a regression in the future. I can totally imagine a future rewrite that tried a different approach than reverse-chronological.
* extract a common function callKartik K. Agaram2022-03-071-2/+3
|
* include caller in sandboxing messagesKartik K. Agaram2022-03-041-1/+1
|
* drop io.lines()Kartik K. Agaram2022-02-021-27/+1
| | | | | | | | | | | | | | | | | I'd already dropped the variant without a filename. But even the variant with a filename is very easy to use in a way that is confusing to use in the presence of sandboxing: * call io.lines() * Sandboxing saves an error, io.lines() returns nil * Caller (usually a loop) raises an error. * We show the error and not the sandboxing failure. * Worse, there's no way to adjust permissions from within Teliva, because we can't ever get to that menu while there's an error. Best solution I can come up with: encourage a separate step for translating filename to file handle. That way it's more obvious that we need to check for errors.
* tweak an entry in the audit logKartik K. Agaram2022-02-021-1/+1
|
* file permissions: decide based on calling functionKartik K. Agaram2022-02-011-2/+2
|
* instrument some obvious syscallsKartik K. Agaram2022-01-021-1/+5
|
* start on a view of audit eventsKartik K. Agaram2022-01-021-0/+4
|
* editable file permissionsKartik K. Agaram2022-01-021-2/+2
| | | | | | | | | | | | | | | | | | | | | Extremely cruddy implementation: - I'm still unclear on how to represent the advice function: - How to handle errors when loading user configuration? Currently I refuse to start. - Whole function? More errors to handle in header and so on. What if the function is renamed? - Just body? Needs more structured editing support. - Lots of duplication, particularly between the permissions in the menu and the permissions screen. I don't know how to show the hostname at the time of connect() or bind(), so networking is going to remain a boolean for now. It's also unclear what effective constraints we can impose on what gets discussed with a specific hostname. Everything outside the computer is out of one's control. One trick I learned is for consistently grabbing ASan logs on abort: It's always safe to redirect stderr with ncurses!
* renameKartik K. Agaram2022-01-021-2/+2
|
* file open() is now sandboxedKartik K. Agaram2021-12-251-3/+14
| | | | | | | In the process we now also have a mechanism for Teliva to overlay errors while apps run. Might make sense to make that available to apps as well. But I'm starting to realize that any app access to the Teliva areas of the screen is fraught with risk.
* drop stdin/stdout/stderr and Lua default filesKartik K. Agaram2021-12-251-115/+13
| | | | | | | This isn't necessarily for sandboxing, but they don't really work right now in the presence of ncurses, and it seems better to not include broken stuff. Maybe we can get them to coexist with ncurses down the road.
* sandbox: no popenKartik K. Agaram2021-12-251-29/+1
| | | | Again, too difficult to sandbox for now.
* new fork of Lua 5.1Kartik K. Agaram2021-10-221-0/+556
https://www.lua.org