Repository navigation
Closed
Description
Problem
Currently, there is no mechanism to control S3 object access based on repository visibility. This creates a security gap:
- All repositories are created as private (
backend/src/routes/datasets.ts:138) - No visibility change mechanism: No code to change repos from private → public
- S3 access is decoupled from repo visibility:
- Private repos should have private S3 data (only accessible with credentials)
- Public repos should have public S3 data (accessible via publicurl)
Current State
- Repos: Created as
private: true - S3 bucket policy: According to
.context/access_control.md, hasPublicReadAccessfor all objects - Git-annex: Uses
publicurlfor all datasets
This means private dataset data files are potentially publicly accessible via S3, which violates the privacy model.
Required Solution
1. Repository Visibility Management
Add admin command to publish a dataset:
nemar admin publish <dataset-id>This should:
- Change GitHub repo from private → public
- Update dataset status in database (
is_publicfield) - Trigger S3 access control update
2. S3 Access Control
Implement two approaches based on visibility:
For Private Datasets:
- No bucket-level public read policy for that prefix
- Use presigned URLs for access (already implemented for uploads)
- Git-annex should not use
publicurlparameter - Only dataset owner can access via presigned URLs
For Public Datasets:
- Apply S3 object ACL or bucket policy allowing public read for that prefix
- Git-annex can use
publicurlfor downloads - Anyone can access via public URL
3. Implementation Tasks
- Add
is_publicboolean field todatasetstable - Create
updateRepositoryVisibility()inbackend/src/services/github.ts - Create
updateS3ObjectAccess()inbackend/src/services/s3.ts - Add POST
/admin/datasets/:id/publishendpoint - Implement
nemar admin publish <dataset-id>command - Update git-annex remote config based on visibility:
- Private: no
publicurl, require credentials - Public: include
publicurlfor web remote access
- Private: no
- Update S3 bucket policy to deny public read by default
- Add S3 object ACL/policy update on publish
4. S3 Bucket Policy Pattern
Current (INSECURE - public read for all):
{
"Sid": "PublicReadAccess",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::nemar/*"
}Proposed (default deny, allow per-prefix):
{
"Sid": "PublicReadOnlyForPublicDatasets",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::nemar/${PublicDatasetPrefix}/*"
}Or use S3 object-level ACLs when publishing.
Testing
- Verify private dataset data is NOT accessible via public URL
- Verify public dataset data IS accessible via public URL
- Verify git-annex can download from public datasets without credentials
- Verify git-annex requires credentials for private datasets
Security Impact
HIGH - Private datasets may currently expose data files publicly if the bucket policy allows it.
References
.context/access_control.md- Current (potentially insecure) bucket policybackend/src/routes/datasets.ts:138- Repos created as privatebackend/src/services/s3.ts- Presigned URL generation (upload only)
Activity
neuromechanist commentedon Feb 2, 2026
addressed by 91