{"record":{"id":"3c2d04e68c792e9b","repo":"ory/hydra","slug":"file-loader-disabled","errorCode":null,"errorMessage":"file loader disabled","messagePattern":"file loader disabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/osx/file.go","lineNumber":157,"sourceCode":"// - WithDisabledFileLoader\n// - WithDisabledHTTPLoader\n// - WithDisabledBase64Loader\n// - WithBase64Encoding\n// - WithHTTPClient\nfunc ReadFileFromAllSources(source string, opts ...Option) (bytes []byte, err error) {\n\treturn readFile(source, newOptions().apply(opts))\n}\n\nfunc readFile(source string, o *options) (bytes []byte, err error) {\n\tparsed, err := url.Parse(source)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse URL\")\n\t}\n\n\tswitch parsed.Scheme {\n\tcase \"\":\n\t\tif o.disableFileLoader {\n\t\t\treturn nil, errors.New(\"file loader disabled\")\n\t\t}\n\n\t\t//#nosec G304 -- false positive\n\t\tbytes, err = os.ReadFile(source)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"unable to read the file\")\n\t\t}\n\tcase \"file\":\n\t\tif o.disableFileLoader {\n\t\t\treturn nil, errors.New(\"file loader disabled\")\n\t\t}\n\n\t\t//#nosec G304 -- false positive\n\t\tbytes, err = os.ReadFile(parsed.Host + parsed.Path)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"unable to read the file\")\n\t\t}\n\tcase \"http\", \"https\":","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/osx/file.go#L139-L175","documentation":"oryx/osx.readFile (reached via RestrictedReadFile / ReadFileFromAllSources) parses the source string as a URL; when the scheme is empty (a plain local path) it consults the o.disableFileLoader option. If file loading has been disabled on the Options, it returns errors.New(\"file loader disabled\") instead of touching the local filesystem. This is a deliberate security guard so restricted contexts cannot read arbitrary local files.","triggerScenarios":"Calling RestrictedReadFile or ReadFileFromAllSources with a bare path (no scheme, e.g. \"/etc/config.yaml\" or \"./data.json\") while the options were created with DisableFileLoader(true) (or equivalent option) set.","commonSituations":"Hardened/embedded deployments that disable the file loader for safety but then a config template or default flag still points at a local path; switching data sources from remote URLs to local files without re-enabling the loader.","solutions":["Remove the DisableFileLoader option from the Options used to construct the reader, if local paths are legitimate in your deployment","Change the source to a URL scheme that is still enabled (e.g. http(s)://) and serve the file over HTTP(S)","Pre-load the file yourself and pass its bytes/content directly instead of a path","Audit who set disableFileLoader (env/config wiring) — in restricted environments the error is intended behavior; move the file to an allowed source"],"exampleFix":"// before\nopts.DisableFileLoader(true)\ndata, err := osx.RestrictedReadFile(\"/etc/app/config.yaml\") // error: file loader disabled\n// after\nopts.DisableFileLoader(false) // or omit the option\ndata, err := osx.RestrictedReadFile(\"/etc/app/config.yaml\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isLocalPath(source string) bool {\n\tu, err := url.Parse(source)\n\treturn err == nil && u.Scheme == \"\"\n}","tryCatchPattern":"data, err := osx.RestrictedReadFile(source)\nif err != nil {\n\tif err.Error() == \"file loader disabled\" {\n\t\t// re-enable the loader or fetch via an enabled scheme\n\t}\n\treturn err\n}","preventionTips":["Decide the allowed source schemes at startup and make config templates match that policy","When DisableFileLoader(true) is set, ensure all configured sources use enabled schemes (http/https)","Centralize reader Options construction so the disable flags are visible in one place","Prefer passing file contents (bytes) instead of paths in restricted environments"],"tags":["go","osx","file-io","security","configuration"],"backgroundTag":"file-loader-disabled","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}